Hi,
thinklogic wrote:
1. Ring 0 = real mode, am i correct?, can you briefly introduce to me why its name "ring" and is there any other rings.
The CPU has several different modes. Real mode is 16 bit, segmented with no protection. Protected mode is a completely different CPU mode.
Protected mode has 4 seperate protection levels (or protection rings). Ring 0 has the least protection, which (in general) can do anything and is normally used for kernel code. Ring 3 has the most protection and is normally used by user programs (to prevent them from accessing memory, IO ports, etc that they shouldn't). Rings 1 and 2 may be used by device drivers or something (or may not be used at all).
I'd consider it a good idea to read Intel's "Software Development Manual, Volume 3: System Programming Guide" from start to end TWICE before starting your kernel. The first time you read it most of it will probably not make much sense. The second time you read it you'll start understanding it. After you think you understand it you'll end up using it as reference material (I'm always looking up something in it).
thinklogic wrote:
2. you said interrupt/exception. can you briefly tell me what is this interrupt, what are the different between the INT 13 we called on BIOS INT (files) with the interrupt / exception you mentioned.
3. what is the relationship of IRQ and INTerrupt? what is IRQ. sometime i see on my windows machine IRQ for COM1/2 port, IRQ for printer, IRQ for VGA and ... what are the relationship of IRQ and PORT? <- i havent understand the concept, hopefully u willing to spend some time to guide me.
Different pieces of electronics (timers, floppy controller, serial ports, video cards, etc) sometimes need to tell the CPU that they need something done. To do this they generate an IRQ (Interrupt ReQuest) by sending a signal on an IRQ line. All of the IRQ lines are connected to a pair of special chips called PIC chips (Programmable Interrupt Controllers). The PIC chips convert the signals on the IRQ lines into an actual interrupt on the CPU's bus. When the CPU notices the special interrupt data on it's bus it generates an interrupt (which isn't much different to a software interrupt (for e.g. "int 0x1A" or "int 0x10") except for what caused it.
In addition the CPU can generate interrupts on it's own, called exceptions. These exceptions are caused by situations that the CPU doesn't know how to handle. For example, if a program tries to access some memory that it's not allowed to access the CPU will generate an exception (for e.g. page fault), which should be handled by the kernel.
All IRQ's, software interrupts and exceptions have a number assigned to it (for e.g. a page fault generates interrupt number 0x0E, and the instruction "int 0x66" generates interrupt number 0x66). This interrupt number is used as an index into a special table. In real mode this table is called the IVT (Interrupt Vector Table), and in protected mode it is called the IDT (Interrupt Descriptor Table). Regardless of what caused the interrupt the CPU looks it up in this table and starts executing the code that the table tells it to.
Getting back to the electronic devices (timers, floppy controller, serial ports, video cards, etc). All of these devices need to be accessable by the CPU. Most of them use IO ports, and some use special memory ranges. Any electronic device could be manufactured to use any IRQ/s, any IO ports and any memory regions, but this would create lots of confusion. To avoid this confusion certain devices always use certain IRQ/s and IO ports. For example, the PIT chip (Programmable Interval Timer chip) always uses IRQ 0 and IO ports 0x40 to 0x5F, while the keyboard controller chip always uses IRQ 1, IRQ 12 and IO ports 0x60 to 0x64. There is no special relationship - mostly it is determined by tradition (backwards compatibility).
thinklogic wrote:
4. i havent got any information about how to check the CPU usage of my developed OS.
You won't have (or need) any information about how to check the CPU usage until your OS is capable of doing more than 1 thing at a time (multi-tasking).
Cheers,
Brendan