osdev

Higher half kernel initialization

走远了吗. 提交于 2019-12-21 05:04:13
问题 When initializing my kernel, I have a few things that need to happen: 1) paging needs to be enabled, 2) the physical memory manager needs to parse the memory map from grub, and 3) assorted startup code needs to access data that needs to stay there for later (e.g. the GDT, IDT, memory management structures). The dependencies between these steps are driving me crazy. With higher-half, the kernel is linked at its virtual address and so the options I've come up with are 1) enable paging in

Higher half kernel initialization

旧时模样 提交于 2019-12-21 05:04:08
问题 When initializing my kernel, I have a few things that need to happen: 1) paging needs to be enabled, 2) the physical memory manager needs to parse the memory map from grub, and 3) assorted startup code needs to access data that needs to stay there for later (e.g. the GDT, IDT, memory management structures). The dependencies between these steps are driving me crazy. With higher-half, the kernel is linked at its virtual address and so the options I've come up with are 1) enable paging in

Setting up IRQ mapping

亡梦爱人 提交于 2019-12-21 04:07:41
问题 I'm following several tutorials and references trying to get my kernel set up. I've come across some unfamiliar code in a tutorial that isn't explaining it at all. It's code that I'm told maps the 16 IRQs (0-15) to ISR locations 32-47 : void irq_remap(void) { outportb(0x20, 0x11); outportb(0xA0, 0x11); outportb(0x21, 0x20); outportb(0xA1, 0x28); outportb(0x21, 0x04); outportb(0xA1, 0x02); outportb(0x21, 0x01); outportb(0xA1, 0x01); outportb(0x21, 0x0); outportb(0xA1, 0x0); } The code for

Disk Read Error while loading sectors into memory

ⅰ亾dé卋堺 提交于 2019-12-20 19:44:23
问题 I tried to develop a bootloader using this, but when it is run it shows: disk read error! If I ignore it, in a later part, it shows me wrong memory mapping. I also followed some other sources too but in vain. It feels like I'm just copying what they are doing. If I do even a little different a new kind of error generates every time. Should I use an already built bootloader or what to do? The code of disk load error is as follow: [org 0x7c00] KERNEL_OFFSET equ 0x1000 mov [BOOT_DRIVE], dl mov

How to load a kernel from disk with BIOS int 13h in NASM assembly?

泄露秘密 提交于 2019-12-20 10:01:57
问题 I've been stuck with this for weeks now and have no idea where I'm going wrong because NASM hasn't given me any errors. The code is pretty self explanatory because of the comments. this is the code that is loaded from the BIOS ;-------------------------------------------- ; 'boot.asm' ; loaded from BIOS [org 0x7C00] [bits 16] ;-------------------------------------------- main: mov ah, 0x0E ; print function mov al, '.' ; ascii char int 0x10 ; IO int resetdisk: mov ah, 0x00 ; reset function mov

Simple kernel won't boot in GRUB

跟風遠走 提交于 2019-12-20 08:36:20
问题 I'm learning a bit of OS development from OSDev.org. I have a kernel and I'm trying to boot in GRUB Legacy (0.97) using qemu. However, when I type kernel 200+9 , I get the message [Multiboot-elf, <0x100000:0x80:0x4008>(bad), entry=0x10000c] This is what I expect except for the (bad) part. If I type boot now GRUB just hangs. I think the numbers 0x100000, 0x44, 0x4008 stand for the .text segment start address, the .bss start address, and the .bss section size, respectively. I think this because

wrong memory locations when debugging in qemu with gdb

我们两清 提交于 2019-12-20 04:37:49
问题 I'm writing a little kernel in assembler. I'm running it in QEMU and have some problems with some bugs. Now I want to debug the kernel with dbg. So I assembled it like so: $ nasm -g -f elf -o myos.elf myos.asm $ objcopy --only-keep-debug myos.elf myos.sym $ objcopy -O binary myos.elf myos.bin Then I run it in QEMU with: $ qemu-system-i386 -s -S myos.bin Then I connect with gdb: $ gdb (gdb) target remote localhost:1234 Remote debugging using localhost:1234 0x0000fff0 in ?? () symbol-file myos

Keyboard interrupt in x86 protected mode causes processor error

荒凉一梦 提交于 2019-12-20 02:59:19
问题 I'm working on a simple kernel and I've been trying to implement a keyboard interrupt handler to get rid of port polling. I've been using QEMU in -kernel mode (to reduce compile time, because generating the iso using grub-mkrescue takes quite some time) and it worked just fine, but when I wanted to switch to -cdrom mode it suddenly started crashing. I had no idea why. Eventually I've realized that when it boots from an iso it also runs a GRUB bootloader before booting the kernel itself. I've

NASM: emit MSW of non-scalar (link-time) value [duplicate]

一个人想着一个人 提交于 2019-12-20 02:33:09
问题 This question already has an answer here : Solution needed for building a static IDT and GDT at assemble/compile/link time (1 answer) Closed 3 months ago . I am attempting to define a constant IDT (Interrupt Descriptor Table) entry in NASM, and to do so, I need to emit into a data table the high word of a double-word address that is not resolved until link time . Is there a way to do it? Here's the interrupt handler: ;;; Interrupt 3 (breakpoint) handler. For now, just poke the screen and halt

Displaying text video memory at 0xb8000 without using the C library

故事扮演 提交于 2019-12-18 12:38:44
问题 I have been writing kernel in C. I've been using the GCC cross-compiler, writing on a Windows system and targeting 16bit Real Mode. I don't have the C library available to write the kernel. I have started with some code which is suppose to print a character directly to the screen. Here is a function from kernel.c : int main() { char *src = (char *)0xB8000000L; *src = 'M'; src += 2; *src = 'D'; return 0; } I compiled my code using GCC with the parameter -m16 to generate code that will run in