![]() |
| ||
| protected mode switch Hello all. I am attempting to write a small operating system, just for kicks (i'm a strange person...), only problem is, i can't seem to make the protected mode switch. I am targeting Intel 80386 and better using NASM to assemble the source. Here is that source: bits 16 Alot of this was borrowed from a tutorial and i would credit them if i could remember the name. This code just makes the processor reset over and over. What is going wrong with this code? I am using bochs to test the code and here is the log file concerning the processor around reset: 00105544372i[BIOS ] Booting from 0000:7c00 Sorry this is so long but i just can't seem to figure out where i am going wrong. I studied all of intel's documents but cant seem to find out where i am going wrong!!!! |
| ||
| Re: protected mode switch The triple fault seems to happen when you execute the jump following the switch into protected mode. That makes me wonder whether the org 0 at the beginning of the file corresponds to where you have the file loaded. Let's say the pmode_jmp label is 256 bytes into the file. Then jmp 0x08:pmode_jmp will translate into jmp 0x8:0x100, which is fine if you want to end up in the middle of the interrupt vector table. If the file was loaded at 0x8000 (say) what you would really want is jmp 0x8:0x8100. To get that you would need to have an org 0x8000 at the beginning of the file. Correspondingly, the jump in the boot sector would then be jmp 0x0000:0x8000 |
| ||
| Re: protected mode switch You're reseting the processor so you come up in real mode, you set your CS and DS segment registers and the first thing you do is use the stack in your video interrupt call! Shouldn't you be setting up your stack as well before you use it? (Just a thought!) Once you get this working your next step will probably be instituting a thunk mechanism so you can thunk down from 32-bit to 16-bit for doing your hardware I/O operations. |
| ||
| Re: protected mode switch Oh and if I remember correctly, you have to initiate the video card before using any of the VIDEO bios interrupts! The graphics chip has to be configured! |
| ||
| Re: protected mode switch Quote:
One of the great joys of writing protected mode operating systems is that, once in protected mode, you can no longer use the BIOS calls (because they were writtent for real mode). Therefore you have to do what the BIOS itself does, and program the hardware directly; usually via i/o ports. |
| ||
| Re: protected mode switch Quote:
|
| ||
| Re: protected mode switch Okay then I'm confused. The original poster xixpsychoxix wants to write his own operating system and he's starting from the reset entry vector. Nothing is initialized at that time. Thus the Video Bios initialization has to be called to configure the GPU so it can be used properly. Or am I missing something? |
| ||
| Re: protected mode switch Quote:
When a PC boots it starts executing at the address 0xFFFF:0000. Since it is running in real mode, and that address is very near the top of the first 1mb, that just leaves room for a jump instruction to a more sensible location. The BIOS code then sets about the business of initioalising the CRT controller, the Programmable interval timer, the keyboard controller, the peripheral interrupt controller, the floppy disk controller, and others. Having done that, it then reads the first sector from track 0 of the floppy disk, if there is one in the drive. By convention that sector is read into memory at 0x0:7c00. The bios then performs a far jump to that location, and the OS bootstrap code begins executing. From looking at his code it appears that he has arranged for the bootstrap code to read his kernel into memory at 0x50:0000. By the time the kernel is read into memory, the CRT controller, which is the only thing which needs initialising for text mode, has already been set up by the BIOS. The "reset" he refers to in his post is known as a triple fault. In this case it is probably the result of an attempt to execute an invalid opcode. The processor then generates an exception, only to find that, as yet, no exception handler has been installed. So then it generates another exception, and then another. Upon the third attempt it gives up the unequal struggle and resets itself. |
| ||
| Re: protected mode switch Yes you're absolutely right. I work with too many processor families and got my INT0 mixed up with Reset on the 80x86 family. And so now it makes more sense, he's not creating an embedded 80x86 product, he's using an off the shelf PC and wants to create his own Operating System for that. Of course you are correct, BIOS is up and running, fully initialized! |
| ||
| Re: protected mode switch Well, i'm just tinkering around with creating my own os for the fun of it, not really because i want to make my own to use. i just program this sort of thing to entertain me and keep my thought process running strong. so i will try to use your ideas here to save my poor operating system and see what i can do. thanx guys |
| All times are GMT -4. The time now is 1:33 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC