[Solved]Unknown Error
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
[Solved]Unknown Error
Hi everyone,
I attempted to load a file that its size is bigger than 64 KB to the memory by loading it in a variable.
I pointed this variable to a point in the memory by malloc.
OK , no problem with it in Virtual PC but if i started doing that in the real hardware the OS restarts automatically.
At first i thought that the problem is in the Floppy Driver, but i didn't find any error in it.
Can anyone help me?
---------------------------------
Thank you in advance.
I attempted to load a file that its size is bigger than 64 KB to the memory by loading it in a variable.
I pointed this variable to a point in the memory by malloc.
OK , no problem with it in Virtual PC but if i started doing that in the real hardware the OS restarts automatically.
At first i thought that the problem is in the Floppy Driver, but i didn't find any error in it.
Can anyone help me?
---------------------------------
Thank you in advance.
Last edited by melgmry0101b on Thu Jul 07, 2011 4:13 am, edited 1 time in total.
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Unknown Error
First, you should try to find out where exactly the problem occurs. Put a "cli" and a "hlt" instruction somewhere in your code and see if the computer still resets or if it just hangs.
Have you set up any exception handlers? It is often very helpful if your OS shows a panic screen and a register dump when an exception occurs, instead of just rebooting.
Have you set up any exception handlers? It is often very helpful if your OS shows a panic screen and a register dump when an exception occurs, instead of just rebooting.
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
Yes , i sat up any exception handlers
About the "CLI" , "STI" and "HLT" i will try.
About the "CLI" , "STI" and "HLT" i will try.
Re: Unknown Error
Are you sure the var you used for the file size isn't 16bit long? Integers in real mode are a word in most of the compilers.
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
My OS is protected mode and the type of the var is "char"
Re: Unknown Error
As for using a char as type for a variable, that cannot be the problem, as chars are stored as 32-bit variables in the non-array case, as putting a single char on the stack would wreck the alignment. (besides, the OP probably meant char * , i guess).
It is still very bad to use char for anything larger that 8 bits.
A floppy disk crash after 64 KiB that isn't there on an emulator sure smells like DMA troubles to me.
It is still very bad to use char for anything larger that 8 bits.
A floppy disk crash after 64 KiB that isn't there on an emulator sure smells like DMA troubles to me.
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
I am writing my OS in C language and i am using "char*" for the var
My DMA points to 0x1200
This error is too strange because i cant get any error code or to debug the kernel because i am in real hardware?
My DMA points to 0x1200
This error is too strange because i cant get any error code or to debug the kernel because i am in real hardware?
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
And about the DMA
I didn't found any error in it because i read that file again but with printing the contents on the screen , the OS ran normally with no errors.
I didn't found any error in it because i read that file again but with printing the contents on the screen , the OS ran normally with no errors.
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Unknown Error
You replied to:-
DLBluunk provided a likely clue:-
Going back to your original post:-
with:-XenOS wrote:First, you should try to find out where exactly the problem occurs. Put a "cli" and a "hlt" instruction somewhere in your code and see if the computer still resets or if it just hangs.
I hope you try it without the STI.Mozo40 wrote:About the "CLI" , "STI" and "HLT" i will try.
DLBluunk provided a likely clue:-
I've never used the DMA (because I used to load with DMA and interrupts off, and now I use the BIOS instead so that I can load from USB floppy), but I have read something about it having a 64KB limit on transfers. Are you trying to load this file in such a way that it's hitting its limit?DLBuunk wrote:A floppy disk crash after 64 KiB that isn't there on an emulator sure smells like DMA troubles to me.
I always work in real hardware - the trick is to find ways of getting the right information out when things go wrong. Send information to the screen periodically to monitor what's going on and to narrow down the point where things go wrong.This error is too strange because i cant get any error code or to debug the kernel because i am in real hardware?
Does that mean you can load it in if you're doing it to print the contents to the screen, but that it goes wrong if you try to load it in to do something else with it? If so, that suggests it may be going wrong after loading successfully, so you need to try the cli hlt thing at the right point to find that out.Mozo40 wrote:And about the DMA
I didn't found any error in it because i read that file again but with printing the contents on the screen , the OS ran normally with no errors.
Going back to your original post:-
If the file is loading properly, are you sure malloc is giving it as much space as it needs and that it isn't overwriting something vital? I don't know how malloc works, but maybe you need to post some of your code so that someone else can check that, though make sure it isn't a loading problem first (by using cli and hlt immediately after the attempt to load it).Mozo40 wrote:I attempted to load a file that its size is bigger than 64 KB to the memory by loading it in a variable.
I pointed this variable to a point in the memory by malloc.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
About the "CLI" , "HLT" and "STI" , i tried it but i didn't get any solutions.
about the limit i read sector by sector each time , not all sectors in one time.
I am in protected mode and i don't have vm86 to use the Bios.DavidCooper wrote:I've never used the DMA (because I used to load with DMA and interrupts off, and now I use the BIOS instead so that I can load from USB floppy), but I have read something about it having a 64KB limit on transfers. Are you trying to load this file in such a way that it's hitting its limit?
about the limit i read sector by sector each time , not all sectors in one time.
I checked it before and it gives me enough space.DavidCooper wrote:If the file is loading properly, are you sure malloc is giving it as much space as it needs and that it isn't overwriting something vital?
Re: Unknown Error
Hi,
I don't see this going anywhere other than around in circles.
@op: As suggested, you need to debug your code. It also sounds like you are making assumptions (or not providing details) about the fact that malloc is working and the FDD driver is working. Are you sure that the FDD driver is playing nicely with your memory allocation routine?
One other thing to check - often when there's a problem with a hardware driver on a real PC but not on a virtual machine, it's to do with timings (look at your port IO). Have you taken in to account the fact that you have to wait for real hardware?
Cheers,
Adam
I don't see this going anywhere other than around in circles.
@op: As suggested, you need to debug your code. It also sounds like you are making assumptions (or not providing details) about the fact that malloc is working and the FDD driver is working. Are you sure that the FDD driver is playing nicely with your memory allocation routine?
One other thing to check - often when there's a problem with a hardware driver on a real PC but not on a virtual machine, it's to do with timings (look at your port IO). Have you taken in to account the fact that you have to wait for real hardware?
Cheers,
Adam
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Unknown Error
If you put cli and hlt into your code immediately after the file has loaded you will find out something vital. If it tripple faults the machine, the fault lies before that point and it's something to do with the way the file's being loaded. If it just hangs, the fault is further on. If it's doing both of those things at the same time, then you've entered some weird quantum state which would excite the likes of Hawking. I don't believe that can have happened - if you do the cli hlt thing properly, you will normally get a useful answer. If you're having difficulty putting it into your code, try putting a conditional jump in front of the cli hlt so that you can activate it at a very specific time just by changing a variable.Mozo40 wrote:About the "CLI" , "HLT" and "STI" , i tried it but i didn't get any solutions.
I was just explaining my lack of knowledge of how the DMA works, but it occurred to me that you might not be resetting it in the right way to ensure that it doesn't hit its 64KB limit by the time it reaches the last part of your >64KB file. If you've checked that properly and it isn't the case, then that's fine, but your first step is still to find out if the tripple fault is caused before the file has finished loading or afterwards - until you do that you're not going to be sure you're looking in the right place to find the error, and the hardest bugs often need to be pinned down to the point where you know for certain that you must be looking right at them even though you still can't see the fault.I am in protected mode and i don't have vm86 to use the Bios.DavidCooper wrote:I've never used the DMA (because I used to load with DMA and interrupts off, and now I use the BIOS instead so that I can load from USB floppy), but I have read something about it having a 64KB limit on transfers. Are you trying to load this file in such a way that it's hitting its limit?
about the limit i read sector by sector each time , not all sectors in one time.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Unknown Error
Thank you for all replies,
I have repaired the problem , It was an error in the floppy not in the memory or the var.
Thank you again.
I have repaired the problem , It was an error in the floppy not in the memory or the var.
Thank you again.