Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bsp/x86/bootsector.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

CYLS = 10
BOOTSEG = 0x07C0
INITSEG = 0x7000
INITSEG = 0x0050

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use #include <common.h> and remove INITSEG here.
BTW: the file name bootsector.s to bootsector.S.

SYSSEG = 0x1000
.code16
.section ".bstext", "ax"
Expand All @@ -21,7 +21,7 @@ main_start:
xorw %sp, %sp


#move BootSector to 0x9000(INITSEG)
#move BootSector to INITSEG
#
movw $BOOTSEG, %ax
movw %ax, %ds
Expand Down Expand Up @@ -181,6 +181,8 @@ fin:
mov $0x13,%al
int $0x10
#
#Jump into INITSEG, rather than SYSSEG, because
#We want to store e820 at $INITSEG:$E820_OFFSET. Our SYSSEG(0x1000) as real start
ljmp $INITSEG, $lowlevel_init
hlt

Expand Down
9 changes: 4 additions & 5 deletions bsp/x86/lowlevel_init.s
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ _lowlevel_init:
nop;
nop;

#Get memory map and store memroy table start from 0x00098004, each entry has 20bytes data but
#Get memory map and store memroy table start from $INITSEG:1004, each entry has 20bytes data but
#currently we reserve 0x20 bytes for each entry
#Each entry has :
#First uint64_t = Base address
Expand All @@ -93,7 +93,8 @@ _lowlevel_init:
# Type 4: ACPI NVS memory
# Type 5: Area containing bad memory
#Set register base https://wiki.osdev.org/Detecting_Memory_(x86)
mov $0x8004, %di
E820_OFFSET=0x1004

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment, move E820_OFFSET to common.h

mov $E820_OFFSET, %di
xor %ebx, %ebx
mov $0x0534D4150, %edx
mov $0xe820,%eax
Expand All @@ -107,8 +108,6 @@ get_next:
int $0x15
cmp $0, %ebx /*ebx=0 means no other entry*/
jnz get_next
#for debug
# hlt

#Inital Serial Device 1
#com1 at 0x3F8
Expand Down Expand Up @@ -185,7 +184,7 @@ fin:
hlt
jmp fin

INITSEG = 0x7000
INITSEG = 0x0050

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


idt_ptr:
.word 0 /* limit */
Expand Down
4 changes: 3 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern struct bitmap_font font;
unsigned int memtest(unsigned int start, unsigned int end);

#define SYSSEG 0x1000
#define INITSEG 0x0050
#define MEMMAN_ADDR (char *)((0x003c0000) - (SYSSEG << 4))
#define VRAM_ADDR (unsigned char *)((0xa0000)-(SYSSEG << 4))
#define COL8_000000 0
Expand All @@ -43,7 +44,8 @@ unsigned int memtest(unsigned int start, unsigned int end);
#define COL8_840084 13
#define COL8_008484 14
#define COL8_848484 15
#define MEM_MAP_ADDR (char *)((0x00078004)-(SYSSEG << 4))
#define E820_OFFSET 0x1004
#define MEM_MAP_ADDR (char *)((INITSEG << 4)+(E820_OFFSET)-(SYSSEG << 4))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is the address after paging? so this PR depend on the paging PR?


struct SEGMENT_DESCRIPTOR {
short limit_low, base_low;
Expand Down