summaryrefslogtreecommitdiff
path: root/kernel/cpu
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-03-17 20:55:34 +0100
committerAnton Kling <anton@kling.gg>2024-03-17 20:55:34 +0100
commit0dccff86e50dfe1555b8bc29862dba2b972a3705 (patch)
tree8d0c354c65278afdc3427bb52e1e63900ccdbc05 /kernel/cpu
parent2e8b474d4219e7faaac3823e73c8d528c2698a37 (diff)
stuff
Diffstat (limited to 'kernel/cpu')
-rw-r--r--kernel/cpu/arch_inst.h1
-rw-r--r--kernel/cpu/arch_inst.s6
-rw-r--r--kernel/cpu/syscall.c12
3 files changed, 13 insertions, 6 deletions
diff --git a/kernel/cpu/arch_inst.h b/kernel/cpu/arch_inst.h
index 54faffb..3d4e1c5 100644
--- a/kernel/cpu/arch_inst.h
+++ b/kernel/cpu/arch_inst.h
@@ -9,3 +9,4 @@ void set_sbp(uintptr_t);
void set_cr3(uintptr_t);
uintptr_t get_cr3(void);
void enable_paging(void);
+void wait_for_interrupt(void);
diff --git a/kernel/cpu/arch_inst.s b/kernel/cpu/arch_inst.s
index aaf34b6..a993172 100644
--- a/kernel/cpu/arch_inst.s
+++ b/kernel/cpu/arch_inst.s
@@ -9,6 +9,7 @@
.global set_cr3
.global get_cr3
.global enable_paging
+.global wait_for_interrupt
get_current_sp:
mov eax, esp
@@ -30,6 +31,11 @@ set_sbp:
mov ebp, eax
ret
+wait_for_interrupt:
+ sti
+ hlt
+ ret
+
halt:
hlt
jmp $
diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c
index c982648..6b260d3 100644
--- a/kernel/cpu/syscall.c
+++ b/kernel/cpu/syscall.c
@@ -53,13 +53,13 @@ int syscall_pread(SYS_PREAD_PARAMS *args) {
return vfs_pread(args->fd, args->buf, args->count, args->offset);
}
-int syscall_read(SYS_READ_PARAMS *args) {
- vfs_fd_t *fd = get_vfs_fd(args->fd);
- if (!fd) {
+int syscall_mread(int fd, void *buf, size_t count, int blocking) {
+ vfs_fd_t *fd_ptr = get_vfs_fd(fd, NULL);
+ if (!fd_ptr) {
return -EBADF;
}
- int rc = vfs_pread(args->fd, args->buf, args->count, fd->offset);
- fd->offset += rc;
+ int rc = vfs_pmread(fd, buf, count, blocking, fd_ptr->offset);
+ fd_ptr->offset += rc;
return rc;
}
@@ -152,7 +152,7 @@ int syscall_tcp_read(u32 socket, u8 *buffer, u32 buffer_size, u64 *out) {
int (*syscall_functions[])() = {
(void(*))syscall_open,
- (void(*))syscall_read,
+ (void(*))syscall_mread,
(void(*))syscall_write,
(void(*))syscall_pread,
(void(*))syscall_pwrite,