Large file bug in Stage2 ?
Moderator:Moderators
Hello
I use Brokenthorn tutorials to devellop my os, specialy the boot (stage 1 and stage 2).
Recently, while testing my new add on my os, it hang with no reason.
With a little investigation, i found it was because my kernel was "too big".
At a certain size, if i add some function or data which are making growing up the size, the system hang.
The problem is in stage 2, Fat12-> LoadFile, and more precisely maybe in Floppy16->ReadSector
Because i have modified stage2 for my OS, i have made some other test.
- take a BrokenThorn Tutorial demo (last for example)
- build project, test it : it works
- just had some data in a source file , ex: char data[n] = { 0,0,0,0,0,0, ...n};
increase executable size untill 50-55 kb
- build project , test it : it fails
It just a size problem, i think
Have you ever had same problem ?
Bug or not ?
I investigate more to have a solution, but if you had one, you're welcome
I use Brokenthorn tutorials to devellop my os, specialy the boot (stage 1 and stage 2).
Recently, while testing my new add on my os, it hang with no reason.
With a little investigation, i found it was because my kernel was "too big".
At a certain size, if i add some function or data which are making growing up the size, the system hang.
The problem is in stage 2, Fat12-> LoadFile, and more precisely maybe in Floppy16->ReadSector
Because i have modified stage2 for my OS, i have made some other test.
- take a BrokenThorn Tutorial demo (last for example)
- build project, test it : it works
- just had some data in a source file , ex: char data[n] = { 0,0,0,0,0,0, ...n};
increase executable size untill 50-55 kb
- build project , test it : it fails
It just a size problem, i think
Have you ever had same problem ?
Bug or not ?
I investigate more to have a solution, but if you had one, you're welcome
Re: Large file bug in Stage2 ?
That may be true, but it has never happened to me. Post any of your findings here, would you? I will edit my version if that is the case.
Re: Large file bug in Stage2 ?
All right , what is your kernel size ?Wolf wrote:but it has never happened to me
Done, have your made test with step decribed in my first post ?Wolf wrote:Post any of your findings here, would you?
Re: Large file bug in Stage2 ?
There is a bug in the code that reads sectors from disk.
It is specifically to do with not putting the correct values into CH/CL for the int 0x13 call
The code is currently being corrected and should be updated soon.
~Andyhhp
It is specifically to do with not putting the correct values into CH/CL for the int 0x13 call
The code is currently being corrected and should be updated soon.
~Andyhhp

Re: Large file bug in Stage2 ?
I have made some test
whatever the size (after critical size limit), the ReadSectors function fail at the same place and same parameters
......
jnc .SUCCESS ; test for read error
xor ax, ax ; BIOS reset disk
int 0x13 ; invoke BIOS
dec di ; decrement error counter
.....
with this parameters
LBA : 0x88
Track : 0x03
Sector : 0x0B
Head : 0x01
Drive : 0x00
May help you
whatever the size (after critical size limit), the ReadSectors function fail at the same place and same parameters
......
jnc .SUCCESS ; test for read error
xor ax, ax ; BIOS reset disk
int 0x13 ; invoke BIOS
dec di ; decrement error counter
.....
with this parameters
LBA : 0x88
Track : 0x03
Sector : 0x0B
Head : 0x01
Drive : 0x00
May help you
Re: Large file bug in Stage2 ?
Are you certain that it fails at that point?whatever the size (after critical size limit), the ReadSectors function fail at the same place and same parameters
That code is the FDD reset command and has nothing relevent to do with reading
~Andrew

Re: Large file bug in Stage2 ?
Sorry, bad COPY/PASTE
2 lines up here
...
int 0x13 ; invoke BIOS
jnc .SUCCESS ; test for read error
xor ax, ax ; BIOS reset disk
int 0x13 ; invoke BIOS
...
But i think the error comme before in LoadFile
I try a solution and give you the result
2 lines up here
...
int 0x13 ; invoke BIOS
jnc .SUCCESS ; test for read error
xor ax, ax ; BIOS reset disk
int 0x13 ; invoke BIOS
...
But i think the error comme before in LoadFile
I try a solution and give you the result
Re: Large file bug in Stage2 ?
seems to be a segment overflow
ES: 0x0000 | BX: 0xFE00
before call int 13h
0xFE00 + 0x200 > 0xFFFF
ES: 0x0000 | BX: 0xFE00
before call int 13h
0xFE00 + 0x200 > 0xFFFF
Re: Large file bug in Stage2 ?
Ok when int 13 function 02 (read sector ) is called, it need ES:BX point to a buffer
At first sector read the value is 0x0000:0x3000, and when your kernel file is more 51 kb (0xFFFF - 0x3000)
you write memory at 0x0000:0x0000
Solution is to add BX/16 to ES and reset BX before continue
At first sector read the value is 0x0000:0x3000, and when your kernel file is more 51 kb (0xFFFF - 0x3000)
you write memory at 0x0000:0x0000
Solution is to add BX/16 to ES and reset BX before continue