Page 1 of 1

Some errors in tutorials

Posted: Sat Apr 26, 2008 8:13 pm
by gzaloprgm
Hi! I've found some bugs in your tutorials.

org 0x10000 ; Kernel starts at 1 MB

(0x10000 = 64KiB)

mov bx, 0x1000 ; BX:BP points to buffer to load to
mov bp, 0x0000 ; load to 1 MB (0x10000)

(0x1000:0 = 64KiB)

jmp 0x8:0x10000 ; jump to our kernel! Note: This assumes Kernel's entry point is at 1 MB

(0x10000 = 1MiB)

Also, kernel can't be bigger than 64KiB or it won't load, because max. addressable mem in real mode with a20 gate active is 1MiB + 64KiB (0xFFFF*16+0xFFFF = 0x10FFEF - 1114095 bytes)

A "times 65537-($-$$) db 0" at end of kernel asm file crashes it.

Any way of loading bigger kernels? Unreal mode maybe?

Loading it to low mem, switching to pmode, copy to high mem, going, to rmode, repeat ?

Thanks,
Gonzalo

Re: Some errors in tutorials

Posted: Sat Apr 26, 2008 9:19 pm
by Mike
Hey,

That 1MB bug was fixed some time ago. If it is still in the tutorials, can you please point out where?
gzaloprgm wrote:Also, kernel can't be bigger than 64KiB or it won't load, because max. addressable mem in real mode with a20 gate active is 1MiB + 64KiB (0xFFFF*16+0xFFFF = 0x10FFEF - 1114095 bytes)
I am very glad that you have brought that up, as you are correct. The only way around this is to either load it from protected mode (instead of real mode), or load it in chunks (Which can be a little ugly.) We can use int 0x15/ah=0x87 to copy the chunk above 1MB.

Some commercial OSs go into protected mode first, and simply load the kernel and kernel mode drivers from protected mode into a virtual address space (Most notably, 3GB mark)

I am going to be looking for more suggestions here that can resolve the problem :)

Re: Some errors in tutorials

Posted: Sat Apr 26, 2008 10:00 pm
by gzaloprgm
Mike wrote:Hey,

That 1MB bug was fixed some time ago. If it is still in the tutorials, can you please point out where?
The texts are all extracted from http://www.brokenthorn.com/Resources/OSDev11.html .
I am very glad that you have brought that up, as you are correct. The only way around this is to either load it from protected mode (instead of real mode), or load it in chunks (Which can be a little ugly.) We can use int 0x15/ah=0x87 to copy the chunk above 1MB.
Thanks, I think a minutes ago I found the solution which works.

I go to unreal mode using osdev wiki code example, and then when I'm loading the image instead of popping and pushing es&bx, I work with es and ebx, so I have 32 bits offset :D

However, I can't make it load more than 137 KB.
(times 137728-($-$$) db 0)

You can see the code at http://gzaloprgm.com.ar/demo4-unrealmode.rar

Hope it helps you,
Gonzalo