-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathearly32.c
More file actions
43 lines (34 loc) · 1.19 KB
/
early32.c
File metadata and controls
43 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "libk/screen.h"
#include "libk/types.h"
#include "x86/cpuid.h"
#include "x86/equipment.h"
#include "x86/vga.h"
#define HANDOVER_TABLE_START 0x600
struct handover_table {
u16 boot_device;
u16 lowmem_k;
u32 video_mem;
u16 equip_flags;
u32 cpu_features1; // cpuid, edx=1
u32 cpu_features2; // cpuid, ecx=1
u8 cpu_name[48]; // cpuid, eax=0
};
// to be able to "b break_point" in gdb
void break_point(void* any) {}
__attribute__((section(".early32"))) void early32(void) {
struct handover_table* t = (struct handover_table*)HANDOVER_TABLE_START;
term_init(t->video_mem);
kprintf("early32: started\n");
kprintf("boot_dev: %x; low_mem: %uK\n", t->boot_device, t->lowmem_k);
u16 videomod = equip_flags_video_mode(t->equip_flags);
u16 serialports = equip_flags_serial_ports(t->equip_flags);
kprintf("video mode: %d\nserial ports: %d\n", videomod, serialports);
cpuid_get_name((u8*)t->cpu_name);
kprintf("cpu_model: %s\n", (int)t->cpu_name);
cpuid_get_features(&t->cpu_features1, &t->cpu_features2);
kprintf("cpu_features: %x %x\n", t->cpu_features1, t->cpu_features2);
clear_screen(VIDEO_MEM_START);
break_point((void*)1);
kprintf("halt.");
__asm__("hlt");
}