Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
if(ata_read_lba28(0, 1, (void*)0x00140000))
print_string("success");
[code]
it prints "success". However if I do a memory dump, the bootsector (what I am reading from the disk) is nowhere to be found.
I am new to making drivers, so the code is probably full of errors....
I will do more debugging, but there might be a blatent error in my driver, so I thought I might as well post it on here.
Also, some people may be offended by that [b]goto[/b], IDGAF.
BMW wrote:Also, some people may be offended by that goto, IDGAF.
You should. You're programming in C, not C64 BASIC. In a structured language like C, goto is often unwise and leads to poorly structured code, and sometimes leads to the introduction of nasty, nasty bugs.
Perhaps you should read "GOTO Considered Harmful". Then again, considering your attitude, perhaps you shouldn't bother. You probably won't learn anything from it.
BMW wrote:Also, some people may be offended by that goto, IDGAF.
You should. You're programming in C, not C64 BASIC. In a structured language like C, goto is often unwise and leads to poorly structured code, and sometimes leads to the introduction of nasty, nasty bugs.
Perhaps you should read "GOTO Considered Harmful". Then again, considering your attitude, perhaps you shouldn't bother. You probably won't learn anything from it.
I am programming in C, exactly. GOTO IS A C STATEMENT!!!!!! (surprise surprise)
And I already told you... IDGAF... lol. I hardly ever use gotos, but in this case I believe it is totally harmless and is an effective solution to a problem.
It is in general. Magic numbers, include guards outside the header, and no respect for maintaining the existing content of bitfields.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Does anyone have anything helpful to say relating to my original question?
Yes.
I will do more debugging
Good choice.
You know that is the answer to your problem. It's really a bit lazy to keep posting code and asking others to debug it for you. You can't keep doing that with every step of your OS. Do you really want to write an OS or are you asking others to do it for you?
You acknowledged in your OP that (a) You need to do more debugging, and (b) The use of the "goto" statement is not likely to encourage others to help you. Heed your own advice.
Does anyone have anything helpful to say relating to my original question?
Yes.
I will do more debugging
Good choice.
You know that is the answer to your problem. It's really a bit lazy to keep posting code and asking others to debug it for you. You can't keep doing that with every step of your OS. Do you really want to write an OS or are you asking others to do it for you?
You acknowledged in your OP that (a) You need to do more debugging, and (b) The use of the "goto" statement is not likely to encourage others to help you. Heed your own advice.
Well I have been debugging for the past half hour... its really wierd... I commented out the line that actually writes the data from the port to memory (*p = inport...) THEN IT PAGE FAULTED...???
And I am not asking people to debug it for me, I just posted it in case there were any blatent errors in my code.
iansjack wrote:OK. What could be going wrong? (Obviously something is not correct.) Look at the simple basics first:
Are you selecting the correct drive?
Are you selecting LBA mode?
Are you setting the correct values in the registers for the LBA addresses?
Read your code with those in mind and see if it helps. You can check the first two by loking at what value you send to port 0x1F6.
Thank you so much, I forgot about setting LBA mode. I was going off some document that said that bit 6 of port 0x1F6 was "reserved" and said it was "always zero"... http://www.nondot.org/sabre/os/files/Disk/IDE-tech.html
Now I get a GPF, but I think I'll be able to sort that out pretty quickly.
On this page: http://wiki.osdev.org/ATA_PIO_Mode about half way down, under x86 directions for 28bit PIO, it has this for step 2:
2. Send a NULL byte to port 0x1F1, if you like (it is ignored and wastes lots of CPU time): outb(0x1F1, 0x00)
Errm... some sort of joke?
EDIT: ATM I am identity mapping the first 4MB of memory. If I make this memory writable, I get a page fault...?? Can you not execute code on a writable page?
EDIT2: Can the kernel write to read only pages by default (WP bit in CR0)?
BMW wrote:Does anyone have anything helpful to say relating to my original question?
Eric S Raymond wrote:Most flames are best ignored — after you've checked whether they are really flames, not pointers to the ways in which you have screwed up, and not cleverly ciphered answers to your real question (this happens as well).
I did point out a bug there...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]