Page 1 of 1
Problems with krnl.sys
Posted: Sat Oct 10, 2009 7:08 am
by Karlosoft
Hi! I've notice a problem. When my kernel is biggest than 50kb, my second stage (part of it, taken by brokenthorn.com) isn't able to load it. i'm using a FAT12 floppy, and the file is correctly loaded in it.
Does anyone have some ideas?
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 7:34 am
by Brendan
Hi,
Karlosoft wrote:Hi! I've notice a problem. When my kernel is biggest than 50kb, my second stage (part of it, taken by brokenthorn.com) isn't able to load it. i'm using a FAT12 floppy, and the file is correctly loaded in it.
Does anyone have some ideas?
All of the code you posted above is wrong!!!
Does that help?
Cheers,
Brendan
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 11:11 am
by qw
Karlosoft wrote:my second stage [...] isn't able to load it.
Karlosoft wrote:and the file is correctly loaded in it.
Is it or isn't it?
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 11:20 am
by Brendan
Hi,
Hobbes wrote:Karlosoft wrote:my second stage [...] isn't able to load it.
Karlosoft wrote:and the file is correctly loaded in it.
Is it or isn't it?
I assumed Karlosoft meant "
the file is correctly copied into the file system".
Cheers,
Brendan
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 11:53 am
by Karlosoft
Yes I meant copied
Well I can't post all the sources of the kernel. The code of the bootloader-stage2 that load my kernel is the same of
this. I've just add some routines to enable vesa and save information from real mode.
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 4:11 pm
by neon
Hello,
Are their any errors or warnings displayed in the bochs crash log or on display?
Re: Problems with krnl.sys
Posted: Sat Oct 10, 2009 4:57 pm
by Brendan
Hi,
Karlosoft wrote:The code of the bootloader-stage2 that load my kernel is the same of
this.
That code uses 16-bit registers to keep track of where to load the next sector into RAM. If you call "LoadFile" with BP = 0, then it'll wrap around after 65536 bytes (and if you call "LoadFile" with BP = 0x8000 you'd only be able to load 32 KiB before it fails).
At the end of "ReadSectors" it does this:
Code: Select all
pop cx
pop bx
pop ax
add bx, WORD [bpbBytesPerSector] ; queue next buffer
inc ax ; queue next sector
loop .MAIN ; read next sector
ret
You might be able to change it to something like:
Code: Select all
pop cx
pop bx
mov ax,es
add ax,512/16
mov es,ax
pop ax
inc ax ; queue next sector
loop .MAIN ; read next sector
ret
Not sure if that'd cause problems elsewhere, but it'd be a start - if it doesn't cause problems elsewhere you'd be able to load about 512 KiB before it fails.
Cheers,
Brendan
Re: Problems with krnl.sys
Posted: Tue Oct 13, 2009 12:44 pm
by Karlosoft
I'll try it in the next days... my computer is dead
. I'm coping my sources on the old.
No error, no warning only a flat black screen
Re: Problems with krnl.sys
Posted: Sun Nov 01, 2009 8:44 am
by Karlosoft
Wow, I've just tried this code but it doesn't work. I did some test and I've found the limit. It is C000 in hex, so 49152... well strange. The filesystem that I'm using is FAT12, I don't remember any restriction on the size of a file. This is my link.ld file... maybe the mistake is here...
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
__CTOR_LIST__ = .; LONG((__CTOR_END__ -
__CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__
= .;
__DTOR_LIST__ = .; LONG((__DTOR_END__ -
__DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ =
.;
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Re: Problems with krnl.sys
Posted: Tue Nov 03, 2009 12:37 pm
by Karlosoft
I have never write nothing in assembly except a pair of line in the C++ code, so it's not easy for me to understand what doesn't work. However i think the problem is in one of the point noticed by Brendan.
The strange thing is that the limit of the copy isn't the register bx that I'm using, but the maximal lenght of the offset. I can copy my kernel up to c000 because c000+3000 (the start offset) is less than ffff. If I move this start limit to 4000 in fact it doesn't work. So how to change the value of the segment pointer??? (I'm not very good to write assembly).