mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-03-15 04:25:06 +00:00
ZealBooter: Misc cleanup, SMP working
This commit is contained in:
parent
fa4ded924f
commit
d7f72e3aa9
5 changed files with 46 additions and 40 deletions
|
@ -70,7 +70,7 @@ if [ ! -d "ovmf" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Testing..."
|
echo "Testing..."
|
||||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -bios ovmf/OVMF.fd
|
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -bios ovmf/OVMF.fd -smp 4
|
||||||
|
|
||||||
echo "Deleting temp folder..."
|
echo "Deleting temp folder..."
|
||||||
rm -rf $TMPDIR
|
rm -rf $TMPDIR
|
||||||
|
|
|
@ -55,8 +55,6 @@ SYS_FONT_PTR:: DU32 0;
|
||||||
SYS_VBE_INFO:: DU8 sizeof(CVBEInfo) DUP(0);
|
SYS_VBE_INFO:: DU8 sizeof(CVBEInfo) DUP(0);
|
||||||
SYS_VBE_MODES:: DU8 sizeof(CVBEModeShort) * VBE_MODES_NUM DUP(0);
|
SYS_VBE_MODES:: DU8 sizeof(CVBEModeShort) * VBE_MODES_NUM DUP(0);
|
||||||
|
|
||||||
ALIGN 16, OC_NOP
|
|
||||||
DU64 0x5439581381193aaf, 0x2a8a30e69ec9f845;
|
|
||||||
SYS_VBE_FINAL_MODE:: DU8 sizeof(CVBEMode) DUP(0);
|
SYS_VBE_FINAL_MODE:: DU8 sizeof(CVBEMode) DUP(0);
|
||||||
SYS_VBE_FINAL_MODE_NUM::DU16 0; //mode number of final mode set
|
SYS_VBE_FINAL_MODE_NUM::DU16 0; //mode number of final mode set
|
||||||
#assert $$ - SYS_KERNEL == sizeof(CKernel) - sizeof(CZXE)
|
#assert $$ - SYS_KERNEL == sizeof(CKernel) - sizeof(CZXE)
|
||||||
|
|
|
@ -82,6 +82,8 @@ SYS_SEMAS:: DU8 SEMA_SEMAS_NUM * DEFAULT_CACHE_LINE_WIDTH DUP(0);
|
||||||
DU64 0xf6ceba7d4b74179a;
|
DU64 0xf6ceba7d4b74179a;
|
||||||
|
|
||||||
CORE0_32BIT_INIT:: //Entry point for $LK,"BootRAM",A="MN:BootRAM"$.
|
CORE0_32BIT_INIT:: //Entry point for $LK,"BootRAM",A="MN:BootRAM"$.
|
||||||
|
CLD
|
||||||
|
|
||||||
PUSH U32 RFLAGG_START
|
PUSH U32 RFLAGG_START
|
||||||
POPFD
|
POPFD
|
||||||
MOV EAX, SYS_START_CR0
|
MOV EAX, SYS_START_CR0
|
||||||
|
|
|
@ -96,7 +96,7 @@ CTSS *TSSNew(I64 cpu_num)
|
||||||
tss->tr = offset(CGDT.tr) + cpu_num * 16;
|
tss->tr = offset(CGDT.tr) + cpu_num * 16;
|
||||||
tss->tr_ring3= offset(CGDT.tr_ring3) + cpu_num * 16;
|
tss->tr_ring3= offset(CGDT.tr_ring3) + cpu_num * 16;
|
||||||
|
|
||||||
d = (0x80d8)(U8 *) + tss->tr;
|
d = (&sys_gdt)(U8 *) + tss->tr;
|
||||||
d1 = d(U8 *) + 4;
|
d1 = d(U8 *) + 4;
|
||||||
*d = 0x0000FFFF;
|
*d = 0x0000FFFF;
|
||||||
*d1 = 0x008F8900;
|
*d1 = 0x008F8900;
|
||||||
|
@ -106,7 +106,7 @@ CTSS *TSSNew(I64 cpu_num)
|
||||||
*d1++ = tss >> 32;
|
*d1++ = tss >> 32;
|
||||||
*d1 = 0;
|
*d1 = 0;
|
||||||
|
|
||||||
d = (0x80d8)(U8 *) + tss->tr_ring3;
|
d = (&sys_gdt)(U8 *) + tss->tr_ring3;
|
||||||
d1 = d(U8 *) + 4;
|
d1 = d(U8 *) + 4;
|
||||||
*d = 0x0000FFFF;
|
*d = 0x0000FFFF;
|
||||||
*d1 = 0x008FE900;
|
*d1 = 0x008FE900;
|
||||||
|
|
|
@ -36,12 +36,12 @@ struct CZXE {
|
||||||
int64_t org;
|
int64_t org;
|
||||||
int64_t patch_table_offset;
|
int64_t patch_table_offset;
|
||||||
int64_t file_size;
|
int64_t file_size;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct CDate {
|
struct CDate {
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
int32_t date;
|
int32_t date;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define MEM_E820_ENTRIES_NUM 48
|
#define MEM_E820_ENTRIES_NUM 48
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ struct CMemE820 {
|
||||||
uint8_t *base;
|
uint8_t *base;
|
||||||
int64_t len;
|
int64_t len;
|
||||||
uint8_t type, pad[3];
|
uint8_t type, pad[3];
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct CGDTEntry {
|
struct CGDTEntry {
|
||||||
uint64_t lo, hi;
|
uint64_t lo, hi;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define MP_PROCESSORS_NUM 128
|
#define MP_PROCESSORS_NUM 128
|
||||||
|
|
||||||
|
@ -75,7 +75,32 @@ struct CGDT {
|
||||||
struct CGDTEntry ds_ring3;
|
struct CGDTEntry ds_ring3;
|
||||||
struct CGDTEntry tr[MP_PROCESSORS_NUM];
|
struct CGDTEntry tr[MP_PROCESSORS_NUM];
|
||||||
struct CGDTEntry tr_ring3[MP_PROCESSORS_NUM];
|
struct CGDTEntry tr_ring3[MP_PROCESSORS_NUM];
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct CVBEInfo {
|
||||||
|
uint8_t signature[4];
|
||||||
|
uint16_t version;
|
||||||
|
uint32_t oem, capabilities, video_modes;
|
||||||
|
uint16_t total_memory, software_revision;
|
||||||
|
uint32_t vendor, product_name, product_revision;
|
||||||
|
uint8_t reserved[222], oem_data[256];
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct CVBEModeShort {
|
||||||
|
uint16_t width, height, mode_num;
|
||||||
|
uint32_t max_pixel_clock;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct CVBEMode {
|
||||||
|
uint16_t attributes, pad0[7], pitch, width, height;
|
||||||
|
uint8_t pad1[3], bpp, pad2, memory_model, pad[12];
|
||||||
|
uint32_t framebuffer;
|
||||||
|
uint16_t pad3[9];
|
||||||
|
uint32_t max_pixel_clock;
|
||||||
|
uint8_t reserved[190];
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
#define VBE_MODES_NUM 32
|
||||||
|
|
||||||
struct CKernel {
|
struct CKernel {
|
||||||
struct CZXE h;
|
struct CZXE h;
|
||||||
|
@ -95,15 +120,19 @@ struct CKernel {
|
||||||
uint8_t *base;
|
uint8_t *base;
|
||||||
} __attribute__((packed)) sys_gdt_ptr;
|
} __attribute__((packed)) sys_gdt_ptr;
|
||||||
uint16_t sys_pci_buses;
|
uint16_t sys_pci_buses;
|
||||||
struct CGDT sys_gdt;
|
struct CGDT sys_gdt __attribute__((aligned(16)));
|
||||||
uint32_t sys_font_ptr;
|
uint32_t sys_font_ptr;
|
||||||
|
struct CVBEInfo sys_vbe_info;
|
||||||
|
struct CVBEModeShort sys_vbe_modes[VBE_MODES_NUM];
|
||||||
|
struct CVBEMode sys_vbe_mode;
|
||||||
|
uint16_t sys_vbe_mode_num;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define BOOT_SRC_RAM 2
|
#define BOOT_SRC_RAM 2
|
||||||
#define RLF_16BIT 0b01
|
#define RLF_16BIT 0b01
|
||||||
#define RLF_VESA 0b10
|
#define RLF_VESA 0b10
|
||||||
|
|
||||||
extern char trampoline[], trampoline_end[];
|
extern symbol trampoline, trampoline_end;
|
||||||
|
|
||||||
struct E801 {
|
struct E801 {
|
||||||
size_t lowermem;
|
size_t lowermem;
|
||||||
|
@ -133,41 +162,18 @@ struct E801 get_E801(void) {
|
||||||
return E801;
|
return E801;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CVBEMode {
|
|
||||||
uint16_t attributes, pad0[7], pitch, width, height;
|
|
||||||
uint8_t pad1[3], bpp, pad2, memory_model, pad[12];
|
|
||||||
uint32_t framebuffer;
|
|
||||||
uint16_t pad3[9];
|
|
||||||
uint32_t max_pixel_clock;
|
|
||||||
uint8_t reserved[190];
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
void _start(void) {
|
void _start(void) {
|
||||||
struct limine_file *kernel = module_request.response->modules[0];
|
struct limine_file *kernel = module_request.response->modules[0];
|
||||||
struct CKernel *CKernel = kernel->address;
|
struct CKernel *CKernel = kernel->address;
|
||||||
|
|
||||||
uintptr_t final_address = 0x7c00;
|
uintptr_t final_address = 0x7c00;
|
||||||
|
|
||||||
struct CVBEMode *sys_vbe_mode;
|
|
||||||
for (uint64_t *p = (uint64_t *)CKernel; ; p++) {
|
|
||||||
if (*p != 0x5439581381193aaf) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
if (*p != 0x2a8a30e69ec9f845) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
sys_vbe_mode = (void *)p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
|
struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
|
||||||
sys_vbe_mode->pitch = fb->pitch;
|
CKernel->sys_vbe_mode.pitch = fb->pitch;
|
||||||
sys_vbe_mode->width = fb->width;
|
CKernel->sys_vbe_mode.width = fb->width;
|
||||||
sys_vbe_mode->height = fb->height;
|
CKernel->sys_vbe_mode.height = fb->height;
|
||||||
sys_vbe_mode->bpp = fb->bpp;
|
CKernel->sys_vbe_mode.bpp = fb->bpp;
|
||||||
sys_vbe_mode->framebuffer = (uintptr_t)fb->address - hhdm_request.response->offset;
|
CKernel->sys_vbe_mode.framebuffer = (uintptr_t)fb->address - hhdm_request.response->offset;
|
||||||
|
|
||||||
void *CORE0_32BIT_INIT;
|
void *CORE0_32BIT_INIT;
|
||||||
for (uint64_t *p = (uint64_t *)CKernel; ; p++) {
|
for (uint64_t *p = (uint64_t *)CKernel; ; p++) {
|
||||||
|
|
Loading…
Reference in a new issue