From 38b1273c7e3a52ae929f36fe07e29bc68ef95102 Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 3 Sep 2018 00:07:20 +0200 Subject: clean filenames etc --- asm/asm_gdt.h | 7 +++++ asm/asm_gdt.s | 39 +++++++++++++++++++++++++ asm/asm_mp.asm | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ asm/asm_mp.h | 2 ++ asm/gdt.h | 1 - asm/gdt.s | 42 --------------------------- asm/mp.asm | 89 ---------------------------------------------------------- asm/mp.h | 2 -- 8 files changed, 137 insertions(+), 134 deletions(-) create mode 100644 asm/asm_gdt.h create mode 100644 asm/asm_gdt.s create mode 100644 asm/asm_mp.asm create mode 100644 asm/asm_mp.h delete mode 100644 asm/gdt.h delete mode 100644 asm/gdt.s delete mode 100644 asm/mp.asm delete mode 100644 asm/mp.h (limited to 'asm') diff --git a/asm/asm_gdt.h b/asm/asm_gdt.h new file mode 100644 index 0000000..523b783 --- /dev/null +++ b/asm/asm_gdt.h @@ -0,0 +1,7 @@ +/** + * @file + * http://wiki.osdev.org/GDT_Tutorial + */ + +/** call as asm_setup_gdt(GDT,sizeof(GDT)) */ +void asm_setup_gdt(uint32_t addr, uint32_t size) diff --git a/asm/asm_gdt.s b/asm/asm_gdt.s new file mode 100644 index 0000000..0e163fc --- /dev/null +++ b/asm/asm_gdt.s @@ -0,0 +1,39 @@ +.global asm_setup_gdt + +asm_setup_gdt: + + // re-fill gdt_descriptor with new GDT location and size + movl 4(%esp),%eax + movl %eax, gdt_descriptor+2 + + movw 8(%esp),%ax + movw %ax, gdt_descriptor + // + + lgdt gdt_descriptor #load new descriptor table! + + // reload to take effect + reloadSegments: + + #Reload CS register containing code selector: + jmp $0x08,$reload_CS # 0x08 points at the new code selector + + reload_CS: + mov $0x10, %ax #0x10 points at the new data selector + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov %ax, %ss + + tss_flush: + + movw $0x2B,%ax # Load the index of our TSS structure - The index is + # 0x28, as it is the 5th selector and each is 8 bytes + # long, but we set the bottom two bits (making 0x2B) + # so that it has an RPL of 3, not zero. + ltr %ax # Load 0x2B into the task state register. + + ret + +ret diff --git a/asm/asm_mp.asm b/asm/asm_mp.asm new file mode 100644 index 0000000..f0eb9c0 --- /dev/null +++ b/asm/asm_mp.asm @@ -0,0 +1,89 @@ +global smp_start +extern smp_main +; master boot record for application processors +;[org 0x7000] +smp_start: +[bits 16] + + cli ;switch off interrupts! + lgdt [gdt_descriptor] ;load descriptor table! + + ;switch on 32-bit protected mode + mov eax, cr0 + or eax,0x1 + mov cr0, eax + + jmp 0x8:init_pm + +[bits 32] + + +LLOCK: dd 0 + +init_pm: + + mov ax, 0x10 + mov ds, ax + mov ss, ax + mov es, ax + mov fs, ax + mov gs, ax + + mov ebp, 0x8000 + mov esp, ebp + + call boot_32_pm ;continue booting in 32-bit protected mode + +boot_32_pm: + hlt + jmp boot_32_pm + + ;mov eax, 1 ; semaphore + ;xchg eax, [LLOCK] + ;cmp eax,1 + ;hlt + ;je $ + ;jmp $ ; loop forever here + + ;call [0x8010] ;kernel_ap ;jump into our Kernel! + call smp_main + + jmp $ ; should never be reached + + +gdt_start: + +gdt_null: ;null descriptor (2 x 4 bytes) + dd 0x0 + dd 0x0 + +gdt_code: + ; flags: + ; present: 1 / privilege: 00 / type: 1 + ; code: 1 / conforming: 0 / readable: 1 / accessed: 0 + ; granularity: 1 / 16-bit default: 1 / 64-bit seg: 0 / AVL: 0 + dw 0xffff ;limit + dw 0x0 ;base + db 0x0 ;base + db 10011010b ;flags + db 11001111b ;flags & seg.limit + db 0x0 ;base + +gdt_data: + ; flags: + ; code: 0 / expand down: 0 / writable: 1 / accessed: 0 + dw 0xffff + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 + +gdt_end: + +gdt_descriptor: + dw gdt_end-gdt_start-1 + dd gdt_start + +CODE_SEG equ gdt_code - gdt_start +DATA_SEG equ gdt_data - gdt_start diff --git a/asm/asm_mp.h b/asm/asm_mp.h new file mode 100644 index 0000000..3ace14a --- /dev/null +++ b/asm/asm_mp.h @@ -0,0 +1,2 @@ +/** Application processors */ +void smp_start(); diff --git a/asm/gdt.h b/asm/gdt.h deleted file mode 100644 index f5bcbd3..0000000 --- a/asm/gdt.h +++ /dev/null @@ -1 +0,0 @@ -void asm_setup_gdt(uint32_t addr, uint32_t size) diff --git a/asm/gdt.s b/asm/gdt.s deleted file mode 100644 index c155ce9..0000000 --- a/asm/gdt.s +++ /dev/null @@ -1,42 +0,0 @@ -//http://wiki.osdev.org/GDT_Tutorial -.global asm_setup_gdt -//.global tss_flush - -// call as setup_gdt(GDT,sizeof(GDT)) -asm_setup_gdt: - - // re-fill gdt_descriptor with new GDT location and size - movl 4(%esp),%eax - movl %eax, gdt_descriptor+2 - - movw 8(%esp),%ax - movw %ax, gdt_descriptor - // - - lgdt gdt_descriptor #load new descriptor table! - - // reload to take effect - reloadSegments: - - #Reload CS register containing code selector: - jmp $0x08,$reload_CS # 0x08 points at the new code selector - - reload_CS: - mov $0x10, %ax #0x10 points at the new data selector - mov %ax, %ds - mov %ax, %es - mov %ax, %fs - mov %ax, %gs - mov %ax, %ss - - tss_flush: - - movw $0x2B,%ax # Load the index of our TSS structure - The index is - # 0x28, as it is the 5th selector and each is 8 bytes - # long, but we set the bottom two bits (making 0x2B) - # so that it has an RPL of 3, not zero. - ltr %ax # Load 0x2B into the task state register. - - ret - -ret diff --git a/asm/mp.asm b/asm/mp.asm deleted file mode 100644 index f0eb9c0..0000000 --- a/asm/mp.asm +++ /dev/null @@ -1,89 +0,0 @@ -global smp_start -extern smp_main -; master boot record for application processors -;[org 0x7000] -smp_start: -[bits 16] - - cli ;switch off interrupts! - lgdt [gdt_descriptor] ;load descriptor table! - - ;switch on 32-bit protected mode - mov eax, cr0 - or eax,0x1 - mov cr0, eax - - jmp 0x8:init_pm - -[bits 32] - - -LLOCK: dd 0 - -init_pm: - - mov ax, 0x10 - mov ds, ax - mov ss, ax - mov es, ax - mov fs, ax - mov gs, ax - - mov ebp, 0x8000 - mov esp, ebp - - call boot_32_pm ;continue booting in 32-bit protected mode - -boot_32_pm: - hlt - jmp boot_32_pm - - ;mov eax, 1 ; semaphore - ;xchg eax, [LLOCK] - ;cmp eax,1 - ;hlt - ;je $ - ;jmp $ ; loop forever here - - ;call [0x8010] ;kernel_ap ;jump into our Kernel! - call smp_main - - jmp $ ; should never be reached - - -gdt_start: - -gdt_null: ;null descriptor (2 x 4 bytes) - dd 0x0 - dd 0x0 - -gdt_code: - ; flags: - ; present: 1 / privilege: 00 / type: 1 - ; code: 1 / conforming: 0 / readable: 1 / accessed: 0 - ; granularity: 1 / 16-bit default: 1 / 64-bit seg: 0 / AVL: 0 - dw 0xffff ;limit - dw 0x0 ;base - db 0x0 ;base - db 10011010b ;flags - db 11001111b ;flags & seg.limit - db 0x0 ;base - -gdt_data: - ; flags: - ; code: 0 / expand down: 0 / writable: 1 / accessed: 0 - dw 0xffff - dw 0x0 - db 0x0 - db 10010010b - db 11001111b - db 0x0 - -gdt_end: - -gdt_descriptor: - dw gdt_end-gdt_start-1 - dd gdt_start - -CODE_SEG equ gdt_code - gdt_start -DATA_SEG equ gdt_data - gdt_start diff --git a/asm/mp.h b/asm/mp.h deleted file mode 100644 index 3ace14a..0000000 --- a/asm/mp.h +++ /dev/null @@ -1,2 +0,0 @@ -/** Application processors */ -void smp_start(); -- cgit v1.2.3