mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 18:43:11 +00:00
Started working on Physical memory map for memory manager
This commit is contained in:
@@ -22,9 +22,9 @@ os: $(BUILD) bootloader kernel $(C_FILES)
|
|||||||
@echo "Building kern.iso..."
|
@echo "Building kern.iso..."
|
||||||
@dd if=/dev/zero of=kern.iso bs=512 count=2880 status=none
|
@dd if=/dev/zero of=kern.iso bs=512 count=2880 status=none
|
||||||
@dd if=$(BUILD)/os.bin of=kern.iso conv=notrunc status=none
|
@dd if=$(BUILD)/os.bin of=kern.iso conv=notrunc status=none
|
||||||
@dd if=$(BUILD)/testfont.bin of=kern.iso bs=512 seek=35 conv=notrunc status=none
|
@dd if=$(BUILD)/testfont.bin of=kern.iso bs=512 seek=36 conv=notrunc status=none
|
||||||
@dd if=$(SRC)/fs/test.txt of=kern.iso bs=512 seek=39 conv=notrunc status=none
|
@dd if=$(SRC)/fs/test.txt of=kern.iso bs=512 seek=40 conv=notrunc status=none
|
||||||
@dd if=$(BUILD)/calc.bin of=kern.iso bs=512 seek=40 conv=notrunc status=none
|
@dd if=$(BUILD)/calc.bin of=kern.iso bs=512 seek=41 conv=notrunc status=none
|
||||||
@echo "\nDone!\n"
|
@echo "\nDone!\n"
|
||||||
|
|
||||||
$(BUILD):
|
$(BUILD):
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
--- Memory Map ---
|
||||||
|
0x1000 - Kernel
|
||||||
|
0x5000 - VBE Mode Info Block
|
||||||
|
0x6000 - Font
|
||||||
|
0x7000 - Filetable (0x7c00 - Bootloader)
|
||||||
|
...
|
||||||
|
0x10000 - Loaded programs
|
||||||
|
|
||||||
+6
-6
@@ -10,12 +10,12 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
filetable:
|
filetable:
|
||||||
db "boot",0,0,0,0,0,0, "bin",0,0,4
|
db "boot",0,0,0,0,0,0, "bin",0,0,5
|
||||||
db "filetable",0, "tab",0,4,1
|
db "filetable",0, "tab",0,5,1
|
||||||
db "kernel",0,0,0,0, "bin",0,5,30
|
db "kernel",0,0,0,0, "bin",0,6,30
|
||||||
db "testfont",0,0, "fnt",0,35,4
|
db "testfont",0,0, "fnt",0,36,4
|
||||||
db "test",0,0,0,0,0,0, "txt",0,39,1
|
db "test",0,0,0,0,0,0, "txt",0,40,1
|
||||||
db "calc",0,0,0,0,0,0, "bin",0,40,2
|
db "calc",0,0,0,0,0,0, "bin",0,41,2
|
||||||
|
|
||||||
times 512-($-$$) db 0
|
times 512-($-$$) db 0
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
#define PROMPT "#> "
|
#define PROMPT "#> "
|
||||||
|
|
||||||
// TODO: Put this at a set address
|
char* filetable = (char*)0x7000; // Pretty sure we don't have to care about the bootloader at 0x7c00
|
||||||
char filetable[512];
|
|
||||||
|
|
||||||
// Function declarations
|
// Function declarations
|
||||||
void printFiletable(char* ft);
|
void printFiletable(char* ft);
|
||||||
@@ -30,14 +29,14 @@ void main() {
|
|||||||
|
|
||||||
// Screen setup
|
// Screen setup
|
||||||
// TODO: Find font in filetable
|
// TODO: Find font in filetable
|
||||||
diskRead(35, 4, (char*)0x6000); // Read font from disk
|
diskRead(36, 4, (char*)0x6000); // Read font from disk
|
||||||
setupScreen();
|
setupScreen();
|
||||||
loadFont((char*)0x6000);
|
loadFont((char*)0x6000);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
print("kern.\n\n");
|
print("kern.\n\n");
|
||||||
|
|
||||||
diskRead(4, 1, filetable); // Read the filetable and store it in memory
|
diskRead(5, 1, filetable); // Read the filetable and store it in memory
|
||||||
|
|
||||||
// Run Interactive Shell Program
|
// Run Interactive Shell Program
|
||||||
// TODO: Make it in another file
|
// TODO: Make it in another file
|
||||||
|
|||||||
+3
-2
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
%define VIDMEM 0xb800
|
%define VIDMEM 0xb800
|
||||||
%define KERNEL_LOC 0x1000
|
%define KERNEL_LOC 0x1000
|
||||||
|
%define FILETAB_LOC 0x7000 ; TODO: Read kernel size and location from ft
|
||||||
%define KERNEL_SIZE 30 ; 15kB
|
%define KERNEL_SIZE 30 ; 15kB
|
||||||
|
|
||||||
start:
|
start:
|
||||||
@@ -25,7 +26,7 @@ start:
|
|||||||
mov bx, 0x7e00 ; 2nd stage bootloader location
|
mov bx, 0x7e00 ; 2nd stage bootloader location
|
||||||
|
|
||||||
; CHS Location
|
; CHS Location
|
||||||
mov al, 3 ; Number of sectors to read (2 = 1kB)
|
mov al, 4 ; Number of sectors to read (4 = 2kB)
|
||||||
mov ch, 0 ; Cylinder
|
mov ch, 0 ; Cylinder
|
||||||
mov dh, 0 ; Head
|
mov dh, 0 ; Head
|
||||||
mov cl, 2 ; Sector
|
mov cl, 2 ; Sector
|
||||||
@@ -68,7 +69,7 @@ loadKernel:
|
|||||||
mov al, KERNEL_SIZE
|
mov al, KERNEL_SIZE
|
||||||
mov ch, 0 ; Cylinder
|
mov ch, 0 ; Cylinder
|
||||||
mov dh, 0 ; Head
|
mov dh, 0 ; Head
|
||||||
mov cl, 6 ; Sector
|
mov cl, 7 ; Sector
|
||||||
mov dl, [driveNum]
|
mov dl, [driveNum]
|
||||||
|
|
||||||
mov ah, 2 ; Read from disk
|
mov ah, 2 ; Read from disk
|
||||||
|
|||||||
+56
-6
@@ -7,6 +7,58 @@
|
|||||||
start:
|
start:
|
||||||
mov [driveNum], dl
|
mov [driveNum], dl
|
||||||
|
|
||||||
|
; Physical memory map setup
|
||||||
|
xor ax, ax
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
|
memMapEntries equ 0x8500
|
||||||
|
getMemoryMap:
|
||||||
|
mov di, memMapEntries + 4 ; 4 bytes after memMapEntries
|
||||||
|
xor ebx, ebx
|
||||||
|
xor bp, bp
|
||||||
|
mov edx, "PAMS" ; SMAP in little endian
|
||||||
|
mov eax, 0xe820
|
||||||
|
mov dword [es:di+20], 1 ; Force valid ACPI 3.X entry
|
||||||
|
mov ecx, 24
|
||||||
|
int 0x15
|
||||||
|
jc .error
|
||||||
|
|
||||||
|
cmp eax, "PAMS"
|
||||||
|
jne .error
|
||||||
|
test ebx, ebx
|
||||||
|
jz .error
|
||||||
|
|
||||||
|
.nextEntry:
|
||||||
|
mov edx, "PAMS" ; In case BIOS messes with edx
|
||||||
|
mov ecx, 24
|
||||||
|
mov eax, 0xe820
|
||||||
|
int 0x15
|
||||||
|
|
||||||
|
jcxz .skipEntry
|
||||||
|
mov ecx, [es:di+8] ; Low 32 bits of length
|
||||||
|
or ecx, [es:di+12] ; High 32 bits of length
|
||||||
|
jz .skipEntry
|
||||||
|
|
||||||
|
; Valid entry
|
||||||
|
inc bp
|
||||||
|
add di, 24 ; Next entry
|
||||||
|
|
||||||
|
.skipEntry:
|
||||||
|
test ebx, ebx
|
||||||
|
jz .done
|
||||||
|
jmp .nextEntry
|
||||||
|
|
||||||
|
.error:
|
||||||
|
mov si, acpiFuncErr
|
||||||
|
call print
|
||||||
|
cli
|
||||||
|
hlt
|
||||||
|
|
||||||
|
.done:
|
||||||
|
mov [memMapEntries], bp
|
||||||
|
clc
|
||||||
|
|
||||||
|
vbeSetup:
|
||||||
; Setup VBE info
|
; Setup VBE info
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
@@ -44,7 +96,7 @@ start:
|
|||||||
cmp ax, 0x4f
|
cmp ax, 0x4f
|
||||||
jne error
|
jne error
|
||||||
|
|
||||||
; Print values
|
; Print values (Debug)
|
||||||
; mov ax, [modeInfoBlock.xRes]
|
; mov ax, [modeInfoBlock.xRes]
|
||||||
; ror ax, 8
|
; ror ax, 8
|
||||||
; call printHex
|
; call printHex
|
||||||
@@ -52,7 +104,6 @@ start:
|
|||||||
; call printHex
|
; call printHex
|
||||||
; mov ax, 0x0e20
|
; mov ax, 0x0e20
|
||||||
; int 0x10
|
; int 0x10
|
||||||
|
|
||||||
; mov ax, [modeInfoBlock.yRes]
|
; mov ax, [modeInfoBlock.yRes]
|
||||||
; ror ax, 8
|
; ror ax, 8
|
||||||
; call printHex
|
; call printHex
|
||||||
@@ -60,13 +111,11 @@ start:
|
|||||||
; call printHex
|
; call printHex
|
||||||
; mov ax, 0x0e20
|
; mov ax, 0x0e20
|
||||||
; int 0x10
|
; int 0x10
|
||||||
|
|
||||||
; xor ax, ax
|
; xor ax, ax
|
||||||
; mov al, [modeInfoBlock.bpp]
|
; mov al, [modeInfoBlock.bpp]
|
||||||
; call printHex
|
; call printHex
|
||||||
; mov ax, 0x0e20
|
; mov ax, 0x0e20
|
||||||
; int 0x10
|
; int 0x10
|
||||||
|
|
||||||
; mov al, 0x0a
|
; mov al, 0x0a
|
||||||
; int 0x10
|
; int 0x10
|
||||||
; mov al, 0x0d
|
; mov al, 0x0d
|
||||||
@@ -218,6 +267,7 @@ driveNum: db 0
|
|||||||
|
|
||||||
vbeErr: db "VBE Error!", 0
|
vbeErr: db "VBE Error!", 0
|
||||||
modeNotFoundErr: db "VBE Mode not found!", 0
|
modeNotFoundErr: db "VBE Mode not found!", 0
|
||||||
|
acpiFuncErr: db "ACPI Function not supported!", 0
|
||||||
|
|
||||||
;; GDT
|
;; GDT
|
||||||
GDT:
|
GDT:
|
||||||
@@ -256,7 +306,7 @@ offset: dw 0
|
|||||||
_segment: dw 0 ; segment is a keyword
|
_segment: dw 0 ; segment is a keyword
|
||||||
mode: dw 0
|
mode: dw 0
|
||||||
|
|
||||||
times 512-($-$$) db 0 ; End Sector 1
|
times (512*2)-($-$$) db 0 ; End Sector 2
|
||||||
|
|
||||||
;; Sector 2
|
;; Sector 2
|
||||||
vbeInfoBlock:
|
vbeInfoBlock:
|
||||||
@@ -331,5 +381,5 @@ modeInfoBlock:
|
|||||||
|
|
||||||
.reserved4: times 190 db 0
|
.reserved4: times 190 db 0
|
||||||
|
|
||||||
times (512*3)-($-$$) db 0 ; 2 Pad out to 3 sectors
|
times (512*4)-($-$$) db 0
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
- [x] Multistage Bootloader
|
- [x] Multistage Bootloader
|
||||||
- [ ] Bootloader reads filetable to find files
|
- [ ] Bootloader reads filetable to find files
|
||||||
- [ ] Makefile refactorin'
|
- [ ] Makefile refactorin'
|
||||||
- [ ] Write down where stuff is in memory (0x1000 - kernel, 0x4000? - filetable, 0x5000 - VBE Mode Info, 0x6000 - Font)
|
- [x] Write down where stuff is in memory
|
||||||
- [ ] "Text" mode (not actually)
|
- [ ] "Text" mode (not actually)
|
||||||
- [ ] Scrolling
|
- [ ] Scrolling
|
||||||
- [ ] Scroll-back
|
- [ ] Scroll-back
|
||||||
|
|||||||
Reference in New Issue
Block a user