summaryrefslogtreecommitdiff
path: root/src/kernel/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/arch')
-rw-r--r--src/kernel/arch/amd64/boot.c6
-rw-r--r--src/kernel/arch/amd64/driver/fsroot.c4
-rw-r--r--src/kernel/arch/amd64/driver/pata.c4
-rw-r--r--src/kernel/arch/amd64/driver/ps2.c8
-rw-r--r--src/kernel/arch/amd64/driver/rtl8139.c10
-rw-r--r--src/kernel/arch/amd64/driver/serial.c6
-rw-r--r--src/kernel/arch/amd64/driver/util.c12
-rw-r--r--src/kernel/arch/amd64/driver/util.h10
-rw-r--r--src/kernel/arch/amd64/driver/video.c8
-rw-r--r--src/kernel/arch/amd64/driver/video.h4
-rw-r--r--src/kernel/arch/amd64/interrupts/isr.c4
-rw-r--r--src/kernel/arch/amd64/pagedir.c22
-rw-r--r--src/kernel/arch/amd64/paging.h2
-rw-r--r--src/kernel/arch/amd64/registers.h6
-rw-r--r--src/kernel/arch/amd64/sysenter.c8
-rw-r--r--src/kernel/arch/amd64/sysenter.h3
-rw-r--r--src/kernel/arch/amd64/time.c16
-rw-r--r--src/kernel/arch/generic.h27
18 files changed, 80 insertions, 80 deletions
diff --git a/src/kernel/arch/amd64/boot.c b/src/kernel/arch/amd64/boot.c
index ed19b79..d78d4f6 100644
--- a/src/kernel/arch/amd64/boot.c
+++ b/src/kernel/arch/amd64/boot.c
@@ -28,7 +28,7 @@ static void *mbi_tag(void *mbi, uint32_t type) {
}
void kmain_early(void *mbi) {
- struct fb_info vid;
+ GfxInfo vid;
struct {
void *addr; size_t len;
} init;
@@ -78,8 +78,8 @@ void kmain_early(void *mbi) {
pci_init();
kprintf("running init...\n");
- process_seed(init.addr, init.len);
- process_switch_any();
+ proc_seed(init.addr, init.len);
+ proc_switch_any();
}
void shutdown(void) {
diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c
index 6217e29..6d3676d 100644
--- a/src/kernel/arch/amd64/driver/fsroot.c
+++ b/src/kernel/arch/amd64/driver/fsroot.c
@@ -8,7 +8,7 @@
#include <kernel/vfs/request.h>
#include <shared/mem.h>
-static int handle(struct vfs_request *req) {
+static int handle(VfsReq *req) {
// TODO document directory read format
// TODO don't hardcode
const char dir[] =
@@ -31,7 +31,7 @@ static int handle(struct vfs_request *req) {
}
}
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
vfsreq_finish_short(req, handle(req));
}
diff --git a/src/kernel/arch/amd64/driver/pata.c b/src/kernel/arch/amd64/driver/pata.c
index 6928b4e..b0ed592 100644
--- a/src/kernel/arch/amd64/driver/pata.c
+++ b/src/kernel/arch/amd64/driver/pata.c
@@ -11,13 +11,13 @@
static const int root_id = 100;
-static void accept(struct vfs_request *req);
+static void accept(VfsReq *req);
void pata_init(void) {
ata_init();
vfs_root_register("/ata", accept);
}
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
int ret;
long id = (long __force)req->id;
char wbuf[4096];
diff --git a/src/kernel/arch/amd64/driver/ps2.c b/src/kernel/arch/amd64/driver/ps2.c
index d0629e6..cdcbf19 100644
--- a/src/kernel/arch/amd64/driver/ps2.c
+++ b/src/kernel/arch/amd64/driver/ps2.c
@@ -17,10 +17,10 @@ static volatile ring_t kb_backlog = {(void*)kb_buf, sizeof kb_buf, 0, 0};
static volatile uint8_t mouse_buf[64];
static volatile ring_t mouse_backlog = {(void*)mouse_buf, sizeof mouse_buf, 0, 0};
-static void accept(struct vfs_request *req);
+static void accept(VfsReq *req);
-static struct vfs_request *kb_queue = NULL;
-static struct vfs_request *mouse_queue = NULL;
+static VfsReq *kb_queue = NULL;
+static VfsReq *mouse_queue = NULL;
static void wait_out(void) {
while ((port_in8(PS2 + 4) & 2) != 0);
@@ -77,7 +77,7 @@ enum {
H_MOUSE,
};
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
// when you fix something here go also fix it in the COM1 driver
int ret;
switch (req->type) {
diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c
index 1face38..dd11102 100644
--- a/src/kernel/arch/amd64/driver/rtl8139.c
+++ b/src/kernel/arch/amd64/driver/rtl8139.c
@@ -10,8 +10,8 @@
#define WAIT -1000
-static void accept(struct vfs_request *req);
-static struct vfs_request *blocked_on = NULL;
+static void accept(VfsReq *req);
+static VfsReq *blocked_on = NULL;
enum {
@@ -105,7 +105,7 @@ void rtl8139_irq(void) {
port_out16(iobase + INTRSTATUS, status);
}
-static int try_rx(struct process *proc, void __user *dest, size_t dlen) {
+static int try_rx(Proc *proc, void __user *dest, size_t dlen) {
uint16_t flags, size;
/* bit 0 - Rx Buffer Empty */
if (port_in8(iobase + CMD) & 1) return WAIT;
@@ -140,7 +140,7 @@ static int try_rx(struct process *proc, void __user *dest, size_t dlen) {
return size;
}
-static int try_tx(struct process *proc, const void __user *src, size_t slen) {
+static int try_tx(Proc *proc, const void __user *src, size_t slen) {
static uint8_t desc = 0;
if (slen > 0xFFF) return -1;
@@ -164,7 +164,7 @@ static int try_tx(struct process *proc, const void __user *src, size_t slen) {
return slen;
}
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
if (!req->caller) {
vfsreq_finish_short(req, -1);
return;
diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c
index 12c4151..6fe4500 100644
--- a/src/kernel/arch/amd64/driver/serial.c
+++ b/src/kernel/arch/amd64/driver/serial.c
@@ -14,8 +14,8 @@ static volatile ring_t backlog = {(void*)backlog_buf, sizeof backlog_buf, 0, 0};
static const int COM1 = 0x3f8;
-static void accept(struct vfs_request *req);
-static struct vfs_request *hung_reads = NULL;
+static void accept(VfsReq *req);
+static VfsReq *hung_reads = NULL;
void serial_init(void) { vfs_root_register("/com1", accept); }
@@ -59,7 +59,7 @@ void serial_write(const char *buf, size_t len) {
serial_putchar(buf[i]);
}
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
int ret;
bool valid;
switch (req->type) {
diff --git a/src/kernel/arch/amd64/driver/util.c b/src/kernel/arch/amd64/driver/util.c
index b2c33c6..957005c 100644
--- a/src/kernel/arch/amd64/driver/util.c
+++ b/src/kernel/arch/amd64/driver/util.c
@@ -5,7 +5,7 @@
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
-int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
+int req_readcopy(VfsReq *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);
@@ -14,7 +14,7 @@ int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
return req->output.len;
}
-void postqueue_join(struct vfs_request **queue, struct vfs_request *req) {
+void postqueue_join(VfsReq **queue, VfsReq *req) {
if (req->postqueue_next)
panic_invalid_state();
@@ -23,16 +23,16 @@ void postqueue_join(struct vfs_request **queue, struct vfs_request *req) {
*queue = req;
}
-bool postqueue_pop(struct vfs_request **queue, void (*accept)(struct vfs_request *)) {
- struct vfs_request *req = *queue;
+bool postqueue_pop(VfsReq **queue, void (*accept)(VfsReq *)) {
+ VfsReq *req = *queue;
if (req == NULL) return false;
*queue = req->postqueue_next;
accept(req);
return true;
}
-void postqueue_ringreadall(struct vfs_request **queue, ring_t *r) {
- struct vfs_request *req;
+void postqueue_ringreadall(VfsReq **queue, ring_t *r) {
+ VfsReq *req;
char tmp[64];
size_t mlen = 0;
if (ring_used(r) == 0) return;
diff --git a/src/kernel/arch/amd64/driver/util.h b/src/kernel/arch/amd64/driver/util.h
index 06ca672..5827fa9 100644
--- a/src/kernel/arch/amd64/driver/util.h
+++ b/src/kernel/arch/amd64/driver/util.h
@@ -1,10 +1,10 @@
#pragma once
+#include <kernel/types.h>
#include <shared/container/ring.h>
#include <stdbool.h>
#include <stddef.h>
-struct vfs_request;
-int req_readcopy(struct vfs_request *req, const void *buf, size_t len);
+int req_readcopy(VfsReq *req, const void *buf, size_t len);
/* compare request path. path MUST be a static string */
#define reqpathcmp(req, path) _reqpathcmp(req, ""path"", sizeof(path) - 1)
@@ -13,9 +13,9 @@ int req_readcopy(struct vfs_request *req, const void *buf, size_t len);
req->input.len == plen && \
memcmp(req->input.buf_kern, path, plen) == 0)
-void postqueue_join(struct vfs_request **queue, struct vfs_request *req);
-bool postqueue_pop(struct vfs_request **queue, void (*accept)(struct vfs_request *));
+void postqueue_join(VfsReq **queue, VfsReq *req);
+bool postqueue_pop(VfsReq **queue, void (*accept)(VfsReq *));
/** If there are any pending read requests, and the ring buffer isn't empty, fulfill them
* all with a single read. */
-void postqueue_ringreadall(struct vfs_request **queue, ring_t *r);
+void postqueue_ringreadall(VfsReq **queue, ring_t *r);
diff --git a/src/kernel/arch/amd64/driver/video.c b/src/kernel/arch/amd64/driver/video.c
index 4cd6b0b..d7046b4 100644
--- a/src/kernel/arch/amd64/driver/video.c
+++ b/src/kernel/arch/amd64/driver/video.c
@@ -9,7 +9,7 @@
#include <shared/mem.h>
#include <shared/printf.h>
-static struct fb_info fb;
+static GfxInfo fb;
static char namebuf[64];
static size_t namelen;
@@ -18,7 +18,7 @@ enum {
H_FB,
};
-static int handle(struct vfs_request *req) {
+static int handle(VfsReq *req) {
switch (req->type) {
case VFSOP_OPEN:
if (!req->input.kern) panic_invalid_state();
@@ -54,7 +54,7 @@ static int handle(struct vfs_request *req) {
}
}
-static void accept(struct vfs_request *req) {
+static void accept(VfsReq *req) {
if (req->caller) {
vfsreq_finish_short(req, handle(req));
} else {
@@ -62,7 +62,7 @@ static void accept(struct vfs_request *req) {
}
}
-void video_init(struct fb_info fb_) {
+void video_init(GfxInfo fb_) {
fb = fb_;
snprintf(namebuf, sizeof namebuf, "%ux%ux%u", fb.width, fb.height, fb.bpp);
namelen = strlen(namebuf);
diff --git a/src/kernel/arch/amd64/driver/video.h b/src/kernel/arch/amd64/driver/video.h
index dfc1710..e9dd8ae 100644
--- a/src/kernel/arch/amd64/driver/video.h
+++ b/src/kernel/arch/amd64/driver/video.h
@@ -1,7 +1,7 @@
#pragma once
#include <stdint.h>
-struct fb_info {
+struct GfxInfo {
char *b;
uint32_t width, height;
uint32_t pitch; /* width in bytes of a single scanline */
@@ -9,4 +9,4 @@ struct fb_info {
uint8_t bpp;
};
-void video_init(struct fb_info);
+void video_init(GfxInfo);
diff --git a/src/kernel/arch/amd64/interrupts/isr.c b/src/kernel/arch/amd64/interrupts/isr.c
index 994519d..1059530 100644
--- a/src/kernel/arch/amd64/interrupts/isr.c
+++ b/src/kernel/arch/amd64/interrupts/isr.c
@@ -62,8 +62,8 @@ void isr_stage3(int interrupt, uint64_t *stackframe) {
log_interrupt(interrupt, stackframe);
cpu_halt();
} else {
- process_kill(process_current, interrupt);
- process_switch_any();
+ proc_kill(proc_cur, interrupt);
+ proc_switch_any();
}
}
}
diff --git a/src/kernel/arch/amd64/pagedir.c b/src/kernel/arch/amd64/pagedir.c
index 4189774..9250a01 100644
--- a/src/kernel/arch/amd64/pagedir.c
+++ b/src/kernel/arch/amd64/pagedir.c
@@ -31,11 +31,11 @@ static __user void *addr_canonize(const __user void *addr) {
}
-struct pagedir *pagedir_new(void) {
+Pagedir *pagedir_new(void) {
return page_zalloc(1);
}
-void pagedir_free(struct pagedir *dir) {
+void pagedir_free(Pagedir *dir) {
for (int i = 0; i < 512; i++) {
if (!dir->e[i].present) continue;
assert(!dir->e[i].large);
@@ -66,7 +66,7 @@ void pagedir_free(struct pagedir *dir) {
}
static pe_generic_t*
-get_entry(struct pagedir *dir, const void __user *virt) {
+get_entry(Pagedir *dir, const void __user *virt) {
pe_generic_t *pml4e, *pdpte, *pde, *pte;
const union virt_addr v = {.full = (void __user *)virt};
@@ -88,7 +88,7 @@ get_entry(struct pagedir *dir, const void __user *virt) {
return pte;
}
-void pagedir_unmap_user(struct pagedir *dir, void __user *virt, size_t len) {
+void pagedir_unmap_user(Pagedir *dir, void __user *virt, size_t len) {
// TODO rewrite this
const void __user *end = addr_canonize(virt + len);
union virt_addr v = {.full = virt};
@@ -144,7 +144,7 @@ void pagedir_unmap_user(struct pagedir *dir, void __user *virt, size_t len) {
}
}
-void pagedir_map(struct pagedir *dir, void __user *virt, void *phys,
+void pagedir_map(Pagedir *dir, void __user *virt, void *phys,
bool user, bool writeable)
{
pe_generic_t *pml4e, *pdpte, *pde, *pte;
@@ -191,13 +191,13 @@ void pagedir_map(struct pagedir *dir, void __user *virt, void *phys,
}
extern void *pagedir_current;
-void pagedir_switch(struct pagedir *dir) {
+void pagedir_switch(Pagedir *dir) {
pagedir_current = dir;
}
// creates a new pagedir with exact copies of the user pages
-struct pagedir *pagedir_copy(const struct pagedir *pml4_old) {
- struct pagedir *pml4_new = page_zalloc(1);
+Pagedir *pagedir_copy(const Pagedir *pml4_old) {
+ Pagedir *pml4_new = page_zalloc(1);
for (int i = 0; i < 512; i++) {
if (!pml4_old->e[i].present) continue;
@@ -239,12 +239,12 @@ struct pagedir *pagedir_copy(const struct pagedir *pml4_old) {
return pml4_new;
}
-bool pagedir_iskern(struct pagedir *dir, const void __user *virt) {
+bool pagedir_iskern(Pagedir *dir, const void __user *virt) {
pe_generic_t *page = get_entry(dir, virt);
return page && page->present && !page->user;
}
-void *pagedir_virt2phys(struct pagedir *dir, const void __user *virt,
+void *pagedir_virt2phys(Pagedir *dir, const void __user *virt,
bool user, bool writeable)
{
pe_generic_t *page = get_entry(dir, virt);
@@ -255,7 +255,7 @@ void *pagedir_virt2phys(struct pagedir *dir, const void __user *virt,
return addr_extract(*page) + ((uintptr_t)virt & PAGE_MASK);
}
-void __user *pagedir_findfree(struct pagedir *dir, char __user *start, size_t len) {
+void __user *pagedir_findfree(Pagedir *dir, char __user *start, size_t len) {
// TODO dogshit slow
pe_generic_t *page;
char __user *iter;
diff --git a/src/kernel/arch/amd64/paging.h b/src/kernel/arch/amd64/paging.h
index 156c0c5..70752b0 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. the name is like this for historical reasons */
+struct Pagedir { /* on amd64 actually points to pml4 */
pe_generic_t e[512];
} __attribute__((packed));
diff --git a/src/kernel/arch/amd64/registers.h b/src/kernel/arch/amd64/registers.h
index b8f6248..5fd09c9 100644
--- a/src/kernel/arch/amd64/registers.h
+++ b/src/kernel/arch/amd64/registers.h
@@ -1,9 +1,9 @@
#pragma once
-#include <camellia/types.h>
+#include <kernel/types.h>
#include <stdint.h>
/* requires 16-byte alignment */
-struct registers {
+struct CpuRegs {
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
uint64_t rdi, rsi;
userptr_t rbp, rsp;
@@ -12,7 +12,7 @@ struct registers {
} __attribute__((__packed__));
// saves a return value according to the SysV ABI
-static inline uint64_t regs_savereturn(struct registers *regs, uint64_t value) {
+static inline uint64_t regs_savereturn(CpuRegs *regs, uint64_t value) {
regs->rax = value;
return value;
}
diff --git a/src/kernel/arch/amd64/sysenter.c b/src/kernel/arch/amd64/sysenter.c
index 459247f..5a96e33 100644
--- a/src/kernel/arch/amd64/sysenter.c
+++ b/src/kernel/arch/amd64/sysenter.c
@@ -3,16 +3,16 @@
#include <kernel/arch/generic.h>
#include <kernel/proc.h>
-struct registers _sysexit_regs;
+CpuRegs _sysexit_regs;
-_Noreturn void sysexit(struct registers regs) {
+_Noreturn void sysexit(CpuRegs regs) {
_sysexit_regs = regs;
_sysexit_real();
}
_Noreturn void sysenter_stage2(void) {
- struct registers *regs = &process_current->regs;
+ CpuRegs *regs = &proc_cur->regs;
*regs = _sysexit_regs;
_syscall(regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9);
- process_switch_any();
+ proc_switch_any();
}
diff --git a/src/kernel/arch/amd64/sysenter.h b/src/kernel/arch/amd64/sysenter.h
index d1274de..03a9f45 100644
--- a/src/kernel/arch/amd64/sysenter.h
+++ b/src/kernel/arch/amd64/sysenter.h
@@ -1,7 +1,8 @@
#pragma once
+#include <kernel/types.h>
// sysenter.c
-extern struct registers _sysexit_regs;
+extern CpuRegs _sysexit_regs;
_Noreturn void sysenter_stage2(void);
// sysenter.s
diff --git a/src/kernel/arch/amd64/time.c b/src/kernel/arch/amd64/time.c
index d6e53dd..0e40521 100644
--- a/src/kernel/arch/amd64/time.c
+++ b/src/kernel/arch/amd64/time.c
@@ -3,7 +3,7 @@
#include <kernel/proc.h>
static uint64_t uptime = 0, goal = ~0;
-static struct process *scheduled = NULL;
+static Proc *scheduled = NULL;
uint64_t uptime_ms(void) { return uptime; }
@@ -16,18 +16,18 @@ void pit_irq(void) {
uptime++;
if (uptime < goal) return;
- struct process *p = scheduled;
+ Proc *p = scheduled;
assert(p);
scheduled = p->waits4timer.next;
- process_transition(p, PS_RUNNING);
+ proc_setstate(p, PS_RUNNING);
update_goal();
}
-void timer_schedule(struct process *p, uint64_t time) {
- process_transition(p, PS_WAITS4TIMER);
+void timer_schedule(Proc *p, uint64_t time) {
+ proc_setstate(p, PS_WAITS4TIMER);
p->waits4timer.goal = time;
- struct process **slot = &scheduled;
+ Proc **slot = &scheduled;
while (*slot && (*slot)->waits4timer.goal <= time) {
assert((*slot)->state == PS_WAITS4TIMER);
slot = &(*slot)->waits4timer.next;
@@ -37,10 +37,10 @@ void timer_schedule(struct process *p, uint64_t time) {
update_goal();
}
-void timer_deschedule(struct process *p) {
+void timer_deschedule(Proc *p) {
assert(p->state == PS_WAITS4TIMER);
- struct process **slot = &scheduled;
+ Proc **slot = &scheduled;
while (*slot && *slot != p)
slot = &(*slot)->waits4timer.next;
assert(*slot);
diff --git a/src/kernel/arch/generic.h b/src/kernel/arch/generic.h
index 0cf4d50..647badc 100644
--- a/src/kernel/arch/generic.h
+++ b/src/kernel/arch/generic.h
@@ -1,10 +1,9 @@
#pragma once
-#include <camellia/types.h>
#include <kernel/arch/amd64/registers.h>
+#include <kernel/types.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
-struct process;
// i have no idea where else to put it
// some code assumes that it's a power of 2
@@ -25,28 +24,28 @@ void shutdown(void);
void cpu_pause(void);
uint64_t uptime_ms(void);
-void timer_schedule(struct process *p, uint64_t time);
-void timer_deschedule(struct process *p);
+void timer_schedule(Proc *p, uint64_t time);
+void timer_deschedule(Proc *p);
// src/arch/i386/sysenter.s
-_Noreturn void sysexit(struct registers);
+_Noreturn void sysexit(CpuRegs);
// all of those can allocate memory
-struct pagedir *pagedir_new(void);
-struct pagedir *pagedir_copy(const struct pagedir *orig);
+Pagedir *pagedir_new(void);
+Pagedir *pagedir_copy(const Pagedir *orig);
-void pagedir_free(struct pagedir *);
-void pagedir_unmap_user(struct pagedir *dir, void __user *virt, size_t len);
-void pagedir_map(struct pagedir *dir, void __user *virt, void *phys,
+void pagedir_free(Pagedir *);
+void pagedir_unmap_user(Pagedir *dir, void __user *virt, size_t len);
+void pagedir_map(Pagedir *dir, void __user *virt, void *phys,
bool user, bool writeable);
-bool pagedir_iskern(struct pagedir *, const void __user *virt);
+bool pagedir_iskern(Pagedir *, const void __user *virt);
-void __user *pagedir_findfree(struct pagedir *dir, char __user *start, size_t len);
+void __user *pagedir_findfree(Pagedir *dir, char __user *start, size_t len);
-void pagedir_switch(struct pagedir *);
+void pagedir_switch(Pagedir *);
// return 0 on failure
-void *pagedir_virt2phys(struct pagedir *dir, const void __user *virt,
+void *pagedir_virt2phys(Pagedir *dir, const void __user *virt,
bool user, bool writeable);
int kprintf(const char *fmt, ...);