summaryrefslogtreecommitdiff
path: root/kern/usermem_asm.S
diff options
context:
space:
mode:
authorHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
committerHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
commitc71294cdd3581c3738d24ffd65414f8644a1094d (patch)
treec86245d50fad9eee4163dbba169bd1839edbf88f /kern/usermem_asm.S
initial commit
Diffstat (limited to 'kern/usermem_asm.S')
-rw-r--r--kern/usermem_asm.S35
1 files changed, 35 insertions, 0 deletions
diff --git a/kern/usermem_asm.S b/kern/usermem_asm.S
new file mode 100644
index 0000000..0eee6f8
--- /dev/null
+++ b/kern/usermem_asm.S
@@ -0,0 +1,35 @@
+/** @file usermem_asm.S
+ *
+ * @brief userspace r/w functions.
+ *
+ * @author Hanjie Wu (hanjiew)
+ * @bug No functional bugs
+ */
+
+.text
+
+.global try_read
+.type try_read, %function
+try_read:
+ mov 0x4(%esp), %eax
+ mov 0x8(%esp), %esi
+ mov (%eax), %al
+ mov %al, (%esi)
+ xor %eax, %eax
+ ret
+
+.global try_write
+.type try_write, %function
+try_write:
+ mov 0x4(%esp), %eax
+ mov 0x8(%esp), %edx
+ mov %dl, (%eax)
+ xor %eax, %eax
+ ret
+
+/* unsuccessful r/w will jump to this function and we return 1 */
+.global usermem_fail
+.type usermem_fail, %function
+usermem_fail:
+ mov $0xffffffff, %eax
+ ret