summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64
diff options
context:
space:
mode:
authordzwdz2022-08-04 23:06:57 +0200
committerdzwdz2022-08-04 23:06:57 +0200
commitce00d1677d7a419b427e7f11963eee982a55a231 (patch)
tree2662c3861226f6909b83d57ff8b6ac3b2ba5ec8d /src/kernel/arch/amd64
parent26dc784103914b9d6ba36e0a96fa4b3af977626f (diff)
do some simple TODOs, organize the rest; general code maintainance
Diffstat (limited to 'src/kernel/arch/amd64')
-rw-r--r--src/kernel/arch/amd64/driver/fsroot.c12
-rw-r--r--src/kernel/arch/amd64/driver/util.c16
-rw-r--r--src/kernel/arch/amd64/driver/util.h4
-rw-r--r--src/kernel/arch/amd64/driver/video.c15
-rw-r--r--src/kernel/arch/amd64/interrupts/isr_stub.s2
-rw-r--r--src/kernel/arch/amd64/paging.h2
-rw-r--r--src/kernel/arch/amd64/sysenter.s2
7 files changed, 26 insertions, 27 deletions
diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c
index 512b7da..41fe136 100644
--- a/src/kernel/arch/amd64/driver/fsroot.c
+++ b/src/kernel/arch/amd64/driver/fsroot.c
@@ -2,6 +2,7 @@
#include <camellia/fsutil.h>
#include <kernel/arch/amd64/ata.h>
#include <kernel/arch/amd64/driver/fsroot.h>
+#include <kernel/arch/amd64/driver/util.h>
#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
@@ -22,17 +23,6 @@ static bool exacteq(struct vfs_request *req, const char *str) {
return req->input.len == len && !memcmp(req->input.buf_kern, str, len);
}
-static int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
- assert(req->type == VFSOP_READ);
- fs_normslice(&req->offset, &req->output.len, len, false);
- virt_cpy_to(
- req->caller->pages, req->output.buf,
- buf + req->offset, req->output.len);
- /* read errors are ignored. TODO write docs */
- return req->output.len;
-}
-
-
static int handle(struct vfs_request *req) {
assert(req->caller);
int id = (int)(long __force)req->id;
diff --git a/src/kernel/arch/amd64/driver/util.c b/src/kernel/arch/amd64/driver/util.c
new file mode 100644
index 0000000..b03e582
--- /dev/null
+++ b/src/kernel/arch/amd64/driver/util.c
@@ -0,0 +1,16 @@
+#include <camellia/fsutil.h>
+#include <kernel/arch/amd64/driver/util.h>
+#include <kernel/mem/virt.h>
+#include <kernel/panic.h>
+#include <kernel/vfs/request.h>
+
+int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
+ if (!req->caller) return -1;
+ assert(req->type == VFSOP_READ);
+ fs_normslice(&req->offset, &req->output.len, len, false);
+ virt_cpy_to(
+ req->caller->pages, req->output.buf,
+ buf + req->offset, req->output.len);
+ /* read errors are ignored. TODO write a spec */
+ return req->output.len;
+}
diff --git a/src/kernel/arch/amd64/driver/util.h b/src/kernel/arch/amd64/driver/util.h
new file mode 100644
index 0000000..fd8d506
--- /dev/null
+++ b/src/kernel/arch/amd64/driver/util.h
@@ -0,0 +1,4 @@
+#pragma once
+
+struct vfs_request;
+int req_readcopy(struct vfs_request *req, const void *buf, size_t len);
diff --git a/src/kernel/arch/amd64/driver/video.c b/src/kernel/arch/amd64/driver/video.c
index 8ace3d4..2d1ac03 100644
--- a/src/kernel/arch/amd64/driver/video.c
+++ b/src/kernel/arch/amd64/driver/video.c
@@ -1,5 +1,6 @@
-#include <camellia/fsutil.h>
#include <camellia/errno.h>
+#include <camellia/fsutil.h>
+#include <kernel/arch/amd64/driver/util.h>
#include <kernel/arch/amd64/driver/video.h>
#include <kernel/mem/virt.h>
#include <kernel/panic.h>
@@ -12,18 +13,6 @@ enum {
H_FB,
};
-/* stolen from fsroot.c, TODO shared copy? i guess? */
-static int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
- if (!req->caller) return -1;
- assert(req->type == VFSOP_READ);
- fs_normslice(&req->offset, &req->output.len, len, false);
- virt_cpy_to(
- req->caller->pages, req->output.buf,
- buf + req->offset, req->output.len);
- /* read errors are ignored. TODO write docs */
- return req->output.len;
-}
-
static int handle(struct vfs_request *req) {
switch (req->type) {
case VFSOP_OPEN:
diff --git a/src/kernel/arch/amd64/interrupts/isr_stub.s b/src/kernel/arch/amd64/interrupts/isr_stub.s
index e45c1c1..c63bf2c 100644
--- a/src/kernel/arch/amd64/interrupts/isr_stub.s
+++ b/src/kernel/arch/amd64/interrupts/isr_stub.s
@@ -75,7 +75,7 @@ _isr_stage2:
iretq
.align 8
-// TODO overflow check
+// TODO stack overflow check
.skip 256 // seems to be enough
.global _isr_mini_stack
_isr_mini_stack:
diff --git a/src/kernel/arch/amd64/paging.h b/src/kernel/arch/amd64/paging.h
index f8de339..156c0c5 100644
--- a/src/kernel/arch/amd64/paging.h
+++ b/src/kernel/arch/amd64/paging.h
@@ -31,7 +31,7 @@ typedef union pe_generic_t {
void *as_ptr;
} pe_generic_t; // pageentry_generic
-struct pagedir { // on amd64 actually points to pml4. TODO more sensible type
+struct pagedir { /* on amd64 actually points to pml4. the name is like this for historical reasons */
pe_generic_t e[512];
} __attribute__((packed));
diff --git a/src/kernel/arch/amd64/sysenter.s b/src/kernel/arch/amd64/sysenter.s
index 1dfb422..8fa8acc 100644
--- a/src/kernel/arch/amd64/sysenter.s
+++ b/src/kernel/arch/amd64/sysenter.s
@@ -36,7 +36,7 @@ stored_rsp:
.skip 8
.global pagedir_current
-// a hack to maintain compat with the old arch api, TODO
+// TODO make into an argument of sysexit
pagedir_current:
.skip 8