summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/hal')
-rw-r--r--arch/x86_64/hal/gdt.c3
-rw-r--r--arch/x86_64/hal/obj.h1
-rw-r--r--arch/x86_64/hal/process.c13
-rw-r--r--arch/x86_64/hal/process.h3
-rw-r--r--arch/x86_64/hal/smp.h1
5 files changed, 18 insertions, 3 deletions
diff --git a/arch/x86_64/hal/gdt.c b/arch/x86_64/hal/gdt.c
index a64bdc1..fc7aa8b 100644
--- a/arch/x86_64/hal/gdt.c
+++ b/arch/x86_64/hal/gdt.c
@@ -53,6 +53,7 @@ void
gdt_setup(processor_t *processor)
{
memcpy(processor->gdt, _gdt, sizeof(struct gdt_entry) * (GDT_TSS_HI+1));
+ memset(processor->iopb, 0, 0x2000);
struct gdt_descriptor gdtr;
gdtr.base = (uintptr_t)&processor->gdt;
@@ -76,6 +77,8 @@ gdt_setup(processor_t *processor)
tss_lo->limit_0_15 = (uint16_t)(tss_limit & 0xFFFF);
tss_lo->limit_flg |= (uint8_t)((tss_limit >> 16) & 0xF);
+ processor->tss.iopb = sizeof(struct tss);
+
extern void load_tss(void);
load_tss();
}
diff --git a/arch/x86_64/hal/obj.h b/arch/x86_64/hal/obj.h
index d28d81b..8955a55 100644
--- a/arch/x86_64/hal/obj.h
+++ b/arch/x86_64/hal/obj.h
@@ -8,6 +8,7 @@
enum
{
JOVE_OBJ_SERIAL_COM = 0x80,
+ JOVE_OBJ_IOPB
};
/*Represents a locked kernel object pointer inside of a object directory.*/
diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c
index 6cc9372..c766a28 100644
--- a/arch/x86_64/hal/process.c
+++ b/arch/x86_64/hal/process.c
@@ -3,11 +3,13 @@
#include "hal/obj.h"
#include "hal/process.h"
#include "hal/smp.h"
+#include "lib/string.h"
#include "init.h"
#include "smp.h"
#include "paging.h"
#include "jove.h"
+PAGEALIGN uint8_t s_init_iopb[0x2000];
PAGEALIGN char s_init_pcb_bytes[0x1000] = { 0 };
static pcb_t *s_init_pcb = (pcb_t*)&s_init_pcb_bytes;
@@ -35,22 +37,29 @@ pcb_pid(pcb_t *pcb)
jove_owned_obj_t*
pcb_rootdir(pcb_t *pcb)
{
- return obj_take(pcb->rootdir);
+ return pcb->rootdir;
}
void
processing_setup(void (*process_main))
{
+ memset(s_init_iopb, 0xFF, 0x2000);
uintptr_t ksp = ((uintptr_t)&s_init_pcb_bytes) + 0xFF8;
s_init_pcb->pid = 1;
s_init_pcb->ksp = (void*)ksp;
s_init_pcb->pml4 = paging_get_pml4();
- s_init_pcb->rootdir = _rootdir_obj;
+ s_init_pcb->rootdir = obj_take(_rootdir_obj);
+
+ jove_owned_obj_t *iopb_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_IOPB_I);
+ obj_settype(iopb_obj, JOVE_OBJ_IOPB);
+ obj_setvalue(iopb_obj, (uintptr_t)s_init_iopb);
processor_t *proc = processor_current();
proc->tss.rsp[0] = (uintptr_t)s_init_pcb->ksp;
+ memcpy(proc->iopb, s_init_iopb, 0x2000);
+
{
jove_owned_obj_t *process_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_PCB_I);
obj_settype(process_obj, JOVE_OBJ_PROCESS);
diff --git a/arch/x86_64/hal/process.h b/arch/x86_64/hal/process.h
index 65b2318..c3530bf 100644
--- a/arch/x86_64/hal/process.h
+++ b/arch/x86_64/hal/process.h
@@ -7,7 +7,8 @@
typedef struct process_control_block
{
pid_t pid;
- jove_obj_t *rootdir;
+ jove_owned_obj_t *rootdir;
+ jove_owned_obj_t *iopb;
uintptr_t pml4;
enum pcb_state state;
diff --git a/arch/x86_64/hal/smp.h b/arch/x86_64/hal/smp.h
index 5813dd3..b208e92 100644
--- a/arch/x86_64/hal/smp.h
+++ b/arch/x86_64/hal/smp.h
@@ -10,6 +10,7 @@ typedef struct processor
{
struct gdt_entry gdt[GDT_TSS_HI+1];
struct tss tss;
+ uint8_t iopb[0x2000];
jove_obj_t *pcb_obj;
pcb_t *pcb;