m1x/x86_64: Load global descriptor table

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-03-25 07:43:36 -04:00
parent b35b559cd9
commit c9a2d08c7e
5 changed files with 37 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ CFLAGS = \
-D_KERNEL \ -D_KERNEL \
-I../../target/ \ -I../../target/ \
-I../../include/ \ -I../../include/ \
-I../../../sdk/include/
.PHONY: all .PHONY: all
all: $(OFILES) $(ASMOFILES) all: $(OFILES) $(ASMOFILES)

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* Provided under the BSD-3 clause
*/
#include <stdint.h>
/* From cpu/locore.S */
extern void md_cpu_lgdt(void *gdtr);
extern char g_GDTR[];
void
hal_cpu_init(void)
{
/* Load the GDT */
md_cpu_lgdt(g_GDTR);
}

View File

@@ -16,6 +16,7 @@ _start:
1: hlt 1: hlt
jmp 1b jmp 1b
.globl md_cpu_lgdt
md_cpu_lgdt: md_cpu_lgdt:
push %r12 push %r12
push %r13 push %r13

14
src/m1x/include/hal/cpu.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* Provided under the BSD-3 clause
*/
#ifndef _HAL_CPU_H_
#define _HAL_CPU_H_ 1
/*
* Initialize the current processor
*/
void hal_cpu_init(void);
#endif /* !_HAL_CPU_H_ */

View File

@@ -4,6 +4,7 @@
*/ */
#include <dev/cons/cons.h> #include <dev/cons/cons.h>
#include <hal/cpu.h>
void void
kmain(void) kmain(void)
@@ -11,5 +12,8 @@ kmain(void)
/* Initialize the console */ /* Initialize the console */
cons_init(); cons_init();
/* Initialize the BSP */
hal_cpu_init();
for (;;); for (;;);
} }