
¡¡
Memory Mapping
¡¡

1.1.2 Memory ±¸Á¶
- SegmentationÀº ProgramÀ» ¿©·¯ Á¶°¢(Segment)À¸·Î ³ª´©¾î Memory °ü¸®¸¦ ÇÏ´Â Memory °ü¸® ±â¹ýÀÌ´Ù.
- Segmentation¿¡¼ ProgramÀÇ Memory ÂüÁ¶(³í¸®ÁÖ¼Ò)´Â SegmentÀÇ Base(½ÃÀÛ) ÁÖ¼Ò¿Í Offset Address·Î ÇÑ´Ù.
- Segment¿¡´Â Code Segment, Data Segment, Stack Segment°¡ ÀÖ´Ù.
- °¢ SegmentÀÇ Base(½ÃÀÛ) ÁÖ¼Ò´Â ÇØ´ç Segment Register·Î ÁöÁ¤µÇ¸ç, °¢ Segment ³»ÀÇ ÁÖ¼Ò ÁöÁ¤Àº Offset Address·Î ÁÖ¾îÁø´Ù. offsetÀº Code SegmentÀÇ °æ¿ì, IP Register¿¡ ÁöÁ¤µÇ¸ç, Stack SegmentÀÇ °æ¿ì, SP Register¿¡ ÁöÁ¤µÈ´Ù. µû¶ó¼, SegmentÀÇ Å©±â´Â 64 KB À̳»ÀÌ´Ù.
- SegmentÀÇ Base Address´Â °¢°¢ Segment Register(CS, DS, SS, ES)ÀÇ °ªÀÌ 4-bit ¿ÞÂÊÀ¸·Î ½¬ÇÁÆ®µÈ °ª(16¹è)À¸·Î ÁöÁ¤µÇ¸ç, Offset Address´Â IP, BP, BX, SP, SI, DI Register µî¿¡ ÁöÁ¤µÈ´Ù.
- Program¿¡¼ »ç¿ëÇÏ´Â ÁÖ¼Ò¸¦ '³í¸®ÁÖ¼Ò(Logical Address)'¶ó Çϴµ¥, ÀÌ´Â 'Segment Base¿Í offset'À¸·Î ±¸¼ºµÈ´Ù.
- Intel ProcessorÀÇ °æ¿ì, ¹°¸®Àû Memory´Â 8-bit ¹ÙÀÌÆ®ÀÇ ¿¬¼ÓÀ¸·Î ±¸¼ºµÇ¸ç, °¢ ¹ÙÀÌÆ®¿¡´Â À¯ÀÏÇÑ ÁÖ¼Ò°¡ ÇÒ´çµÇ´Âµ¥ À̸¦ Physical Address(¹°¸®ÁÖ¼Ò)¶ó Çϸç, Address Bus¿¡ ½Ç¸®´Â ÁÖ¼Ò°¡ ¹Ù·Î ÀÌ Physical AddressÀÌ´Ù.
- Physical Address = Segment *10H +offset
1.1.3 I/O Interface
1.1.4 Interrupt System
1. Interrupt Á¾·ù
- Hardware Interrupt : CPUÀÇ NMI¿Í INTR ÇÉÀ¸·Î ÀνĵǴ ¿ÜºÎ Interrupt
- Software Interrupt : INT ¸í·ÉÀ¸·Î ¹ß»ýµÈ´Ù.
- ³»ºÎ Interrupt : ¸í·É ¼öÇà½Ã fault·Î ¹ß»ý(Overflow, Divide by 0, Breakpoint, Single step)
- ÃÑ Interrupt Áö¿ø °¡´É ¼ö´Â 256°³ÀÌ´Ù.
2. Interrupt ¿ì¼± ¼øÀ§
- ³»ºÎ Interrupt(fault) > NMI > Software Interrupt > Hardware Interrupt
- °°Àº ¿ì¼± ¼øÀ§ÀÇ Interrupt¿¡¼´Â ŸÀԳѹö(0¡255)°¡ ÀÛÀº °ÍÀÌ ¿ì¼± ¼øÀ§°¡ ³ô´Ù.
- º¸Åë ŸÀԳѹö Áß 0, 1 ,3, 4¿¡ ³»ºÎInterrupt, 2¿¡ NMI°¡, 32¡255¿¡´Â Software ¹× Hardware Interrupt°¡ ÇÒ´çµÈ´Ù(5¡31Àº ÃßÈÄ »ç¿ëÀ» À§ÇØ ¿¹¾àµÊ).
- ¿ì¼± ¼øÀ§ Interrupt¸¸, ÇöÀç ¼öÇàµÇ´Â Interrupt ó¸® ·çƾ ¼öÇà Áß¿¡µµ ÀÎÁöµÈ´Ù.
3. Interrupt Vector Table(Interupt Vector Table; IVT)
- Interrupt ó¸® Interface ±¸Á¶·Î Interrupt Vector TableÀ» »ç¿ëÇÑ´Ù.
- Interrupt Vector Table¿¡´Â 256°³±îÁöÀÇ Interrupt Handler ÁÖ¼Ò 4¹ÙÀÌÆ®(CS, IP)°¡ ÀúÀåµÈ´Ù.
- ´ÙÀ½ Fig-Àº i8086/i8088 CPUÀÇ Interrupt Vector Table ±¸Á¶¸¦ º¸¿©ÁØ´Ù.
1.1.5 Real-mode
1.1.6 DOSÀÇ Memory map
1.2. Protected Mode
1. i80286 Architecture
2. Protected-mode
1. 16-bit Segment Register (CS, DS, SS, ES)
|
15 3 |
2 |
1 0 |
|
INDEX |
TABLE |
RPL |
| Fig- A.6 80286 Selector ±¸Á¶ | ||
- RPL(Required Privilege Level) : 0ÀÎ °æ¿ì ÃÖ»óÀ§ Level
- TABLE : 1ÀÎ °æ¿ì LDT , 0ÀÎ °æ¿ì GDT
- INDEX : Descriptor Table(LDT, GDT)ÀÇ 8192°³ÀÇ Segment DescriptorÀÇ offset À§Ä¡¸¦ ÁöÁ¤Çϸç, Processor´Â À妽º °ª¿¡ 8À» °öÇÏ°í ±× °á°ú¸¦ Descriptor TableÀÇ Base Address¸¦ °¡»êÇÏ¿© ´ëÀÀ Descriptor¸¦ ã´Â´Ù.
2. 16-bit ÀÏ¹Ý Register(AX, BX, CX, DX, BP, SI, DI, SP)
3. 16-bit IP, 16-bit Status Register(Flag Status Register, ¸Ó½Å Status Register)
4. 16-bit Selector(TR, LDTR), 48-bit GDTR, IDTR
1.2.3 Mode Àüȯ
- Protected-mode·ÎÀÇ Àüȯ Àü¿¡ ¹Ýµå½Ã GDTR ¹× IDTR Register°¡ ÃʱâȵǾî¾ß ÇÑ´Ù.
- ÀÌÈÄ LGDT, LIDT ¸í·ÉÀ» ÀÌ¿ëÇÏ¿© GDT, IDTÀ» »ý¼ºÇÑ ´ÙÀ½, LMSW ¸í·ÉÀ¸·Î ¸Ó½Å Status RegisterÀÇ PE¸¦ 1·Î setÇϸé, Protected-mode·Î ÀüȯµÈ´Ù.
- Protected-mode ÀüȯÁ÷ÈÄ, »ç¿ëÀÚ´Â Intersegment(Far) Jump ¸í·ÉÀ» ¼öÇàÇÏ¿© CS¸¦ ÀûÀçÇϰí, Instruction Queue¸¦ û¼ÒÇØ¾ß ÇÑ´Ù.
- ¶Ç, ¸ðµç Data ¹× Code Selector¸¦ ÃʱâÈÇÏ¿© Task°¡ Protected-mode¿¡¼ µ¿ÀÛÇÒ È¯°æ Áغñ¸¦ ¿Ï·áÇÑ´Ù.
1.2.4 Protected-mode
1. i80286 CPUÀÇ Protected-mode
2. Segment Descriptor
- SegmentÀÇ Base Address À§Ä¡, Å©±â(Limit), Privilege Level(Ư±Ç) Control, Status Á¤º¸¸¦ Á¦°øÇÏ´Â ÀڷᱸÁ¶·Î Descriptor´Â Compiler, ·Î´õ, ¶Ç´Â O/S¿¡ ÀÇÇØ »ý¼ºµÇ¸ç, ÀÀ¿ëProgram¿¡ ÀÇÇØ¼´Â »ý¼ºµÇÁö ¾Ê´Â´Ù.
- Segment Descriptor¿¡´Â Code ¹× Data Segment Descriptor, System Segment Descriptor(GDT¿¡ Á¸Àç) µîÀÌ ÀÖÀ¸¸ç, Å©±â´Â 8¹ÙÀÌÆ®ÀÌ¸ç ±× ±¸Á¶´Â ´ÙÀ½ Fig-°ú °°´Ù.
¡¡
| Bit | ||||
|
0 0 0 0(reserved) 0 0 0 0 |
7 |
|||
|
0 0 0 0(reserved) 0 0 0 0 |
6 |
|||
|
P |
DPL |
S |
TYPE |
5 |
|
Segment Base(D16 - D23) |
4 |
|||
|
Segment Base(D8 - D15) |
3 |
|||
|
Segment Base(D0 - D7) |
2 |
|||
|
Segment Limit (D8 - D15) |
1 |
|||
|
Segment Limit (D0 - D7) |
0 |
|||
| Fig- A.7 80286 Segment Descriptor ±¸Á¶ | ¡¡ | |||
3. GDT(Global Descriptor Table)
- System(O/S)¿¡ ÇÊ¿äÇÑ Code ¹× Data Segment, Task Status Segment µîÀÇ Descriptor ¹× Àü¿ªÀûÀ¸·Î »ç¿ëµÇ´Â DescriptorµéÀÇ Table
- GDT Register(GDTR)´Â GDTÀÇ Å©±â¿Í Base Á¤º¸¸¦ º¸À¯ÇÑ´Ù.
- Windows´Â ±âµ¿½Ã¿¡ GDT¸¦ »ý¼ºÇÑ´Ù.
- GDT¿¡ ÀÖ´Â Segment Descriptor´Â ´ëºÎºÐ 0(Ring-0)ÀÌ¾î¼ ÀÀ¿ë ProgramÀÌ Á¢±ÙÇÒ ¼ö ¾ø´Ù.
- Ring-0 Program¸¸ÀÌ LGDT ¸í·ÉÀ» ÅëÇØ GDTRÀÇ ³»¿ëÀ» º¯°æÇÒ ¼ö ÀÖÀ¸¸ç SGDT¸¦ ÅëÇØ GTRÀÇ ³»¿ëÀ» ¹ß°ßÇÒ ¼ö ÀÖ´Ù.
4. LDT(Local Descriptor Table)
- ÁÖ¾îÁø ÀÀ¿ë Program¿¡ ÀÌ¿ë °¡´ÉÇÑ DescriptorµéÀÇ Table
- °¢ ÀÀ¿ë¿¡ ´ëÇØ, °¢°¢ ´Ù¸¥ LDTÀ» ÇÒ´çÇÏ¿© °¢ ÀÀ¿ëµéÀ» ¼·Î µ¶¸³½ÃÄÑ MultitaskingÀÌ °¡´ÉÇÏ°Ô ÇÑ´Ù.
- Memory ³»¿¡ LDTÀÇ Base Address´Â ´ÙÀ½ Á¤º¸·Î ¾ò¾îÁø´Ù.
- LDTÀÇ Base Address Á¤º¸´Â GDT ³»ÀÇ LDT Descriptor¿¡ Á¸ÀçÇÑ´Ù.
- GDT ³»ÀÇ ÇöÀçÀÇ LDT Descriptor À§Ä¡ Á¤º¸´Â LDTR¿¡ Á¸ÀçÇÑ´Ù.
- Windows-95/98´Â °¢ °¡»ó ¸Ó½Å¸¶´Ù µ¶ÀÚÀÇ LDT¸¦ »ý¼ºÇÑ´Ù.
- LLDT ¸í·ÉÀº LDTR Register¸¦ ÀûÀçÇϴ Ư±Ç ¸í·ÉÀ̸ç, SLDT´Â LDTR Register ³»¿ëÀ» Àд ¸í·ÉÀÌ´Ù.
5. IDT(Interrupt Descriptor Table)
- 256°³ÀÇ Interrupt HandlerÀÇ ³í¸® ÁÖ¼Ò(Segment Selector¿Í Offset Address) Á¤º¸, Á¢±Ù ±ÇÇÑ µîÀÇ Á¤º¸¸¦ °®´Â Interrupt(Gate) DescriptorµéÀÇ Table
- IDTR Register´Â IDTÀÇ Å©±â¿Í Base Address¸¦ Æ÷ÇÔÇÑ´Ù.
- IDT´Â Processor Interrupt Handler¸¦ ÁöÁ¤ÇÏ´Â Gate(Gate)¸¦ Æ÷ÇÔÇÑ´Ù.
- WindowsIDT´Â Interrupt 0¡5Fh¿¡ ´ëÇÑ entry¸¸À» °®À¸¸ç, 60h¿¡¼ FFh¿¡ À̸£´Â Interrupt´Â INT¸í·ÉÀ» ¼öÇàÇÏ´Â Software¿¡ ÀÇÇØ ¹ß»ýµÉ ¼ö ÀÖ´Ù.
6. TSS(Task State Segment) : Task ¼öÇàÀ» º¹±Í½Ã۴µ¥ ÇÊ¿äÇÑ Processor StatusÁ¤º¸¸¦ Æ÷ÇÔÇÑ´Ù.
7. TSS Descriptor : TSSÀÇ Base Address¿Í Å©±â Á¤º¸¸¦ °®À¸¸ç, GDT¿¡ À§Ä¡ÇÑ´Ù.
8. TR : GDT ³»¿¡ TSS Descriptor offset À§Ä¡ Á¤º¸¸¦ °®´Â Selector
9. Gate Descriptor
- ´Ù¸¥ Ư±Ç LevelÀÇ ½ÇÇà°¡´É Segment »çÀÌÀÇ ¼öÇàÁ¦¾î ÀüÀ̸¦ À§ÇÑ º¸È£ Á¦°øÀ» À§ÇØ Á¦°øµÇ¸ç, 4Á¾·ùÀÇ Gate Descriptor°¡ ÀÖ´Ù.
- Call Gates : ÀÀ¿ë¿¡¼ System ÇÔ¼ö È£Ã⠵ »ç¿ë
- Trap Gates : Software Interrupt³ª ¿¹¿Ü 󸮿¡ »ç¿ë
- Interrupt Gates : ÁÖ·Î Hardware Interrupt 󸮿¡ »ç¿ë
- Task Gates : Task Àüȯ¿¡ »ç¿ë
1.2.5 Memory ±¸Á¶
- SelectorÀÇ °ªÀº ÇØ´ç Descriptor Table(GDT ¶Ç´Â LDT)¿¡¼ ÇØ´ç Segment DescriptorÀÇ offset À§Ä¡¸¦ ÁöÁ¤ÇÑ´Ù. °¢ ÇØ´ç Segment Descriptor¿¡´Â 'Segment Address' Á¤º¸¸¦ º¸À¯ÇÑ´Ù.
- 'Segment Address'+'Offset Address'À» 'Linear Address'¶ó Çϴµ¥, PagingÀÌ Áö¿øµÇ¸é ½ÇÁ¦ Physical Address °è»êÀ» À§ÇØ ÀÌ Linear Address´Â ´Ù½Ã ÁÖ¼Ò º¯È¯À» °®´Âµ¥, 80286¿¡¼´Â µû·Î PagingÀ» Áö¿øÇÏÁö ¾ÊÀ¸¹Ç·Î ¹Ù·Î ÀÌ Linear Address°¡ Physical Address°¡ µÈ´Ù.
1.2.6 Interrupt¿Í ¿¹¿Ü
1.2.7 Protection Mechanism
1. º¸È£´Â ÇÑ Task°¡ ´Ù¸¥ TaskÀÇ Data³ª ¸í·ÉÀ» Ä§ÇØÇÏ´Â °ÍÀ» ¸·¾Æ ½Å·Ú¼º ÀÖ´Â MultitaskingÀÌ °¡´ÉÇÏ°Ô ÇÑ´Ù.
2. Program °³¹ßµµÁß¿¡´Â Program ¹ö±×¿¡ ´ëÇÑ º¸´Ù ºÐ¸íÇÑ Fig-À» Á¦°øÇÒ ¼ö ÀÖÀ¸¸ç, ¿£µåÀ¯Àú Program¿¡¼´Â ProgramÀÌ ½ÇÆÐÇÏ´Â °æ¿ì¶óµµ ±× ¿µÇâÀÌ ´Ù¸¥ Program¿¡ ÀüÆÄµÇÁö ¾Ê°Ô ÇÑ´Ù.
º¸È£´Â Segment¿Í Page ¸ðµÎ¿¡ Àû¿ëµÉ ¼ö Àִµ¥, i80286Àº PagingÀ» Áö¿øÇÏÁö ¾ÊÀ¸¹Ç·Î Segment Level¿¡¼ÀÇ º¸È£ mechanism¸¸ ÀÖ´Ù.
3. Memory ÂüÁ¶½Ã¿¡ Memory »çÀÌŬÀÌ ½ÃÀ۵DZâ Àü¿¡ º¸È£°¡ ¸¸Á·µÇ´Â Áö°¡ È®ÀεǸç, º¸È£ Á¡°ËÀº ÁÖ¼Òº¯È¯°ú µ¿½Ã¿¡ ¼öÇàµÇ¹Ç·Î ¼º´ÉÀÇ ¿È´Â ¾ø´Ù.
4. º¸È£ Á¡°Ë¿¡´Â ´ÙÀ½ÀÌ ÀÖ´Ù.
- ŸÀÔüũ
- Limit üũ
- ÁÖ¼ÒÂüÁ¶°¡ °¡´ÉÇÑ ¿µ¿ªÀÇ Á¦ÇÑ
- Procedure entry Æ÷ÀÎÆ®ÀÇ Á¦ÇÑ
- ¸í·ÉsetÀÇ Á¦ÇÑ
5. º¸È£ Á¡°Ë À§¹Ý½Ã¿¡´Â fault(Fault)°¡ ¹ß»ýµÈ´Ù.
6. ŸÀÔ °Ë»ç
- ŸÀÔfield¿¡´Â ¾²±â °¡´É, Àб⠰¡´É µîÀÌ ÀÖ´Ù.
- ŸÀÔ°Ë»ç´Â ÇÁ·Î±×·¡¸Ó¿¡ ÀÇÇØ ÀǵµµÈ ¹æ¹ý°ú ´Ù¸£°Ô Segment¸¦ »ç¿ëÇÏ·Á´Â ProgramÀÇ ¿¡·¯¸¦ °¨ÁöÇÏ¸ç ¸·´Â´Ù.
7. Limit °Ë»ç
: Segment DescriptorÀÇ Limit field´Â ProgramÀÌ Segment ¹ÛÀ¸·Î ÁÖ¼Ò ÁöÁ¤ÇÏ´Â °ÍÀ¸·Î ¸·´Â´Ù.
8. Ư±Ç Level(Privilege Levels) °Ë»ç
- Ư±Ç LevelÀº 0, 1, 2, 3ÀÇ 4LevelÀÌ ÀÖÀ¸¸ç, LevelÀÌ ³·À»¼ö·Ï Ư±ÇÀÌ ³ô´Ù.
- ÇöÀçÀÇ CS Segment SelectorÀÇ ÇÏÀ§ 2bitsÀÇ RPLÀ» CPL(Current Privilege Level)À̶ó Çϸç, CPLÀº Á¦¾î°¡ ´Ù¸¥ Ư±ÇLevelÀ» °®´Â Code Segment·Î ÀüÀ̵Ǵ °æ¿ì ¹Ù²ï´Ù.
- Segment Descriptor¿¡´Â DPL(Descriptor Privilege Level) field°¡ ÀÖÀ¸¸ç, ÀÌ´Â ÇØ´ç Segment¿¡ Àû¿ëµÇ´Â Ư±ÇLevelÀÌ´Ù.
- Segment Selector¿¡´Â RPL(Requester Privilege Level) field°¡ Á¸ÀçÇϸç, ÀÌ´Â Selector¸¦ »ý»êÇÑ ÇÁ·Î½ÃÀúÀÇ Æ¯±ÇLevelÀ» ³ªÅ¸³½´Ù. ¸¸¾à, ´õ ³ôÀº Ư±ÇLevel ProgramÀÌ ´õ ³·Àº Ư±Ç Level ProgramÀ¸·ÎºÎÅÍ Selector¸¦ ¹ÞÀ¸¸é, RPLÀº ´õ ³·Àº Level·Î Memory Á¢±ÙÀÌ ÀÌ·ç¾îÁö°Ô ÇÑ´Ù.
- ProgramÀÌ ÀÚ±â(CPL)º¸´Ù Ư±ÇLevelÀÌ ³ôÀº Code³ª Data Segment¸¦ Á¢±ÙÇÏ·Á ÇÒ ¶§, General-Protection Fault°¡ ¹ß»ýÇÑ´Ù. O/S´Â ÀڱⰡ °ü¸®ÇÏ´Â Code¿Í DataÀÇ DPLÀ» 0À¸·Î Çϸé, ÀÀ¿ëÀº O/S Data¸¦ Á¢±ÙÇÒ ¼ö ¾øÀ¸¸ç, O/S System ÇÔ¼ö¸¦ È£ÃâÇÒ ¼ö ¾ø´Ù.
- O/S´Â ÀÀ¿ë¿¡°Ô Á¦¾îµÈ System ÁøÀÔÁ¡À» Á¦°øÇϱâ À§ÇØ, Call Gate(GDT ¶Ç´Â LDT¿¡ À§Ä¡)¶ó´Â ±¸Á¶¸¦ »ç¿ëÇÑ´Ù.
- Call Gate ¿¡´Â ¸ñÀû Segment Descriptor°¡ ÀÖ´Â °ÍÀÌ ¾Æ´Ï°í, À̸¦ À妽ÌÇÏ´Â Selector¿Í offset Á¤º¸¿Í Call GateÀÇ DPL Á¤º¸¸¦ °®°í ÀÖ´Ù.
- Call Gate¸¦ »ç¿ëÇÑ °æ¿ì, ´ÙÀ½ÀÇ ±ÔÄ¢ÀÌ ¸¸Á·µÇ¸é, GeneralProtection Fault°¡ ¹ß»ýÇÏÁö ¾Ê´Â´Ù.
- GateÀÇ DPLÀÌ CPL°ú °°°í, ¸ñÀû Code SegmentÀÇ RPLÀÌ CPLº¸´Ù ³ô´Ù.
9. Protected-mode¿¡¼ÀÇ ¸í·É setÀÇ Á¦ÇÑ
- LGDT, LLDT, LIDT., LMSW, HALT µîÀº Ư±ÇLevelÀÌ 0ÀÎ DPL ¿¡°Ô¸¸ Çã¶ôµÈ´Ù.
- STI/CLI ¹× I/O ÀåÄ¡ Á¢±Ù(IN, OUT ¹× ÆÄ»ý ¸í·É) µîÀÇ ¸í·É ¼öÇàÀº CPLÀÌ IOPL(Protected-mode Flag Register¿¡ À§Ä¡)º¸´Ù ³ô°Å³ª °°À» ¶§(Áï, CPLÀÇ °ªÀÌ IOPL °ªº¸´Ù ³·°Å³ª °°À» ¶§) ¼öÇàµÈ´Ù.
- ¸¸¾à IOPLÀÌ CPLº¸´Ù ³ôÀ» ¶§¿¡´Â, TSSÀÇ I/O Çã¿ë map(Permission Map)ÀÌ Á¶»çµÇ¾î ÇØ´ç I/O Æ÷Æ®ÀÇ -bit°¡ clear(=0) µÇ¾î ÀÖÀ¸¸é, ±× Æ÷Æ®·Î ÀÔÃâ·Â ¸í·É ¼öÇàÀÌ °¡´ÉÇÏ´Ù.
1.2.8 Windows-3.xÀÇ Memory map
1-3.1 °³¿ä
¡¡
- Paging Çã¿ë
- °¢ VM-86 ÀÀ¿ë¿¡ µû¸¥ °¢°¢ÀÇ I/O Æ÷Æ® Á¢±Ù Çã¿ëÀÇ Á¦¾î°¡ °¡´É
- Interrupt Flag¿¡ ¿µÇâÀ» ¹ÌÄ¡´Â ¸í·ÉÀÇ Æ®·¦ÀÌ °¡´É
1-3.2 Real-mode
1. Real-mode Processor ±¸Á¶
2. È®ÀåµÈ ¸®¾ó -mode ¸í·É
- PUSH, PUSHA : Stack¿¡ ÀúÀå, ¸ðµç General Register¸¦ Stack¿¡ ÀúÀå
- POPA : Stack¿¡ ÀúÀåµÈ ¸ðµç General Register º¹±Í
- IMUL : Á¤¼ö °ö¼À
- INS, OUTS : ½ºÆ®¸µ ÀÔÃâ·Â
- ENTER, LEAVE : Procedure·ÎÀÇ ÁøÀÔ, ÅðÃâ
- BOUND
1-3.3 Protected-modeÀÇ ÀÌÇØ
- Segmentation »Ó¸¸ ¾Æ´Ï¶ó Paging Áö¿ø
- Address Bus °¡ 32-bit¿©¼, SegmentÀÇ Å©±â°¡ ÃÖ´ë 4GB±îÁöÀ̸ç, Flat Memoryµµ Áö¿øÇÑ´Ù.
1-3.4 Protected-mode Software ±¸Á¶
1-3.4.1 Protected-modeÀÇ Processor Model
- °¢ Register¿¡ ´ëÇÑ º¸´Ù ÀÚ¼¼ÇÑ ¼³¸íÀº ºÎ·Ï ÂüÁ¶¸¦ ÂüÁ¶. ¿©±â¼´Â System Flag Register, Control Register µî¿¡ ´ëÇØ Á» ´õ »ó¼úÇÑ´Ù.
- System Flag RegisterÀÎ EFLAGS RegisterÀÇ System Flag´Â I/O, Maskable Interrupts, Debugging, Task Àüȯ, VM-86 µîÀ» Á¦¾îÇÑ´Ù.
- System Flag StatusÀÇ º¯°æ µîÀÇ Á¶ÀÛÀº ¾ö°ÝÈ÷ Á¦ÇѵǸç, ¾î±æ °æ¿ì ¿¹¿Ü(Exception°¡ ¹ß»ýµÈ´Ù.
- VM(VM-86, bit 17) : set½Ã¿¡ Virtual-86-mode·Î µ¿ÀÛ
- IOPL(I/O Privilege Level, bits 12 and 13) : º¸È£ mechanism¿¡ ÀÇÇØ I/O ÁÖ¼Ò°ø°£ÀÇ Á¢±ÙÀ» Á¦¾îÇϴµ¥ »ç¿ëµÈ´Ù.
- IF(Interrupt-Enable Flag, bit 9) : IF Flag set½Ã¿¡ Maskable Interrupts (INTR Interrupts)¸¦ ¹Þ¾ÆµéÀÏ ¼ö ÀÖÀ¸¸ç, clear µÇ´Â °æ¿ì INTR Interrupts´Â ¹Þ¾Æµé¿©ÁöÁö ¾Ê´Â´Ù. NMI¿Í Software Interrupt, ¿¹¿Ü¿¡´Â ¿µÇâÀ» ¹ÌÄ¡Áö ¾Ê´Â´Ù.
1-3.4.2 Control Register
- Paging Memory °ü¸®°¡ »ç¿ëµÇ´Â °æ¿ì, Paging fault½Ã¿¡ CR2´Â ¿¹¿Ü¸¦ ÃÊ·¡ÇÑ 32-bit Linear Address(Linear Address)¸¦ º¸À¯ÇÑ´Ù.
- Paging Memory °ü¸®°¡ »ç¿ëµÇ´Â °æ¿ì, CR3´Â Page Address Table(Page Directory) Á¤º¸¸¦ Á¦°øÇÑ´Ù.
- System ±¸Á¶ÀÇ °ø½ÄÀûÀÎ ºÎºÐÀº ¾Æ´Ï³ª, TLB(Translation Lookaside Buffer)¿Í Cache¸¦ Å×½ºÆÃÇϴµ¥ Á¦°øµÇ´Â ±¸Çö ÀÇÁ¸Àû Áö¿ø±¸Á¶ÀÌ´Ù.
- Debugging Register (Debugging Register)
- 386 Processor´Â 8°³ÀÇ Debugging Register¸¦ °®´Â´Ù.
- DR0¡DR3Àº Breakpoint ÁÖ¼Ò¸¦ °®´Â´Ù.
- ³ª¸ÓÁö Debugging Register´Â Processor°¡ Debugging ¿¹¿Ü¸¦ ¾î¶»°Ô ¹ß»ýÇÏ´À³Ä¸¦ Á¦¾îÇÑ´Ù.
- GDT, LDT, IDT : 80286ÀÇ °æ¿ì¿Í µ¿ÀÏ
1-3.5 Interrupts
- Protected-mode Interrupt 󸮴 80286ÀÇ °æ¿ì¿Í µ¿ÀÏÇÏ´Ù.
- VM-86¿¡¼ Interrupt ¹ß»ý½Ã¿¡´Â Ring-0 Stack¿¡ GS, FS, DS, ES µîÀÇ ³»¿ëÀ» ÀúÀåÇϰí À̵é Segment Register ³»¿ëÀ» ¸ðµÎ 0À¸·Î setÇÑ´Ù. SS:ESP, EFLAGS, CS:EIP¸¦ Ring-0 Stack¿¡ ÀúÀåÇÑ´Ù.
1-3.6 Windows-95/98ÀÇ Interrupt ó¸®
- Real-mode BIOS´Â PIC¸¦ IRQ 0h¿¡¼ 7h´Â Interrupt Vector 8h¿¡¼ Fh·Î, IRQ 8h¿¡¼ Fh´Â Interrupt Vector 70h¿¡¼ 77h·Î Program ÇÏ¿´±â ¶§¹®¿¡ IRQ 5ÀÇ Interrupt Handler´Â Hardware Interrupt ¶§¹®ÀÎÁö, ¾Æ´Ï¸é Processor ¹ß»ý General Protection Fault ¶§¹®ÀÎÁö¸¦ ÆÇº°ÇÏ±â ¾î·Æ´Ù.
- Windows´Â IRQ 0h¿¡¼ Fh¸¦ Interrupt Vector 50h¿¡¼ 5Fh·Î ÇÒ´çÇÏ¿´±â ¶§¹®¿¡ Real-mode¿Í °°Àº Interrupt ¿øÀΠȥµ¿À» ÇÇÇÒ ¼ö ÀÖ´Ù.
- IRQ 0Ch(º¸Åë Bus¸¶¿ì½º Interrupt)¿Í NetBIOS Interrupt ¸ðµÎ INT 5Ch·Î ³ªÅ¸³ª´Âµ¥, ÀÌ °æ¿ì, Windows´Â IDT Gate¿¡ ¿¬°üµÈ Ư±Ç LevelÀ» »ç¿ëÇÏ¿© ProgramÀÌ INT 5Ch¸¦ »ç¿ëÇÒ ¶§ GP fault¸¦ ¹ß»ý½ÃÄÑ NetBIOS·Î Á¦¾î±Ç À̾çÀÌ °¡´ÉÇÏ°Ô ÇÔÀ¸·Î½á Interrupt ¿øÀΠȥµ¿À» ÇÇÇÑ´Ù.
1-3.7 Protected-mode Memory °ü¸®
- Memory °ü¸®´Â Segmentation°ú PagingÀ¸·Î ±¸¼ºµÈ´Ù.
- Segmentation Hardware´Â ³í¸®ÁÖ¼Ò¸¦ ¿¬¼ÓµÇ°í, Segment µÇÁö ¾ÊÀº ÁÖ¼Ò°ø°£ÀÎ Linear Address(Linear Address)·Î º¯È¯Çϸç, PagingÀÌ ¾ø´Â °æ¿ì¿¡ ÀÌ Linear Address°¡ °ð¹Ù·Î Physical Address°¡ µÇ¸ç, PagingÀÌ »ç¿ëµÇ´Â °æ¿ì, Paging Hardware°¡ Linear Address¸¦ Physical Address·Î º¯È¯ÇÑ´Ù.
- Paging
- Å©°í ºÐÇҵǾî ÀÖÁö ¾ÊÀº(Unsegmented) ÁÖ¼Ò°ø°£À» ÀÛ°í ´ÜÆíȵÈ(Fragmented) ÁÖ¼Ò°ø°£(Page)°ú ¾î¶² µð½ºÅ© °ø°£(Swap space)À» ÀÌ¿ëÇÏ¿© ½Ã¹Ä·¹ÀÌ¼Ç Çϴµ¥ »ç¿ëµÇ´Â Memory °ü¸® mechanismÀÌ´Ù.
- 80386 ÀÌ»óÀÌ Áö¿øÇÏ´Â PageÅ©±â´Â 4K bytesÀÌ´Ù.
- ProgramÀÌ µð½ºÅ©¿¡ ÀÖ´Â Page¸¦ ÂüÁ¶ÇÏ·Á ÇÒ ¶§, ¿¹¿Ü(Page Fault)°¡ ¹ß»ýµÇ¸ç, ÀÌ ¶§, ÇØ´ç Page¸¦ µð½ºÅ©¿¡¼ Memory·Î ÀûÀçÇϰí, ¹°¸®Àû ÁÖ¼Ò·Î mappingÀÌ ÀÌ·ç¾î Áø ÈÄ¿¡, ¿¹¿Ü¸¦ ¹ß»ý½ÃŲ ¸í·ÉÀÌ ´Ù½Ã ¼öÇà(Instruction Restart)µÈ´Ù.
- 16-bit ProgramÀÇ °æ¿ì, SegmentÀÇ Å©±â°¡ 64K À̳»À̹ǷÎ, PagingÀ» »ç¿ëÇÏÁö ¾Ê°í Àüü Segment¸¦ swapping ÇÏ´Â°Ô È¿À²ÀûÀÌ´Ù.
1-3.8 Flat Model
- Flat Model¿¡¼´Â CS, DS, SS, ESÀÇ ¸ðµç Segment°¡ °°Àº ÁÖ¼Ò °ø°£( 4GB)À¸·Î mappingµÇ¾î ¸ðµÎ °°Àº Base Address¸¦ °¡Áö¸ç, SegmentÀÇ offsetÀÌ Code ¿µ¿ªÀ̳Ä, Data ¿µ¿ªÀ̳ĸ¦ ³ªÅ¸³½´Ù.
- Flat ModelÀ» À§ÇØ Àû¾îµµ µÎ °³ÀÇ Segment Descriptor°¡ ÇÊ¿äÇÏ´Ù. Çϳª´Â Code ÂüÁ¶¸¦ À§ÇØ, ´Ù¸¥ Çϳª´Â Data ÂüÁ¶¸¦ À§ÇØ, µÎ °³ÀÇ Segment Descriptor´Â °°Àº Base Address¸¦ °®´Â´Ù.
»ç½Ç»ó ÇÑ Segment¹Û¿¡ Á¸ÀçÇÏÁö ¾ÈÀ¸¹Ç·Î ¾î¶² ŸÀÔÀÇ Memory ÂüÁ¶µµ ÀÓÀÇ Å¸ÀÔÀÇ Data Á¢±ÙÀ» Çã¿ëÇÑ´Ù.
![]()
1-3.9 Multi-Segment Model
- °¢ ProgramÀº Çѹø¿¡ 6°³±îÁö Segment(CS, DS, SS, ES, FS, GS)°¡ »ç¿ëµÉ ¼ö ÀÖÀ¸¸ç, °¢ Segment DescriptorÀÇ TableÀÌ ÁÖ¾îÁø´Ù.
°¢ Segment´Â µ¶¸³ÀûÀ̸ç, º¸È£µÇ¸ç, SegmentÀÇ Limit(4Gbytes±îÁö °¡´É)¸¦ ³Ñ´Â Memory ÂüÁ¶½Ã¿¡´Â General-ProtectionÀÌ ¹ß»ýÇÑ´Ù.
¡¡
1-3.10 Segment Translation
- SegmentÀÇ ³í¸® ÁÖ¼Ò´Â 16bit Segment Selector¿Í 32bit offsetÀ¸·Î ±¸¼ºµÇ¸ç, ³í¸®ÁÖ¼Ò´Â SegmentÀÇ Base Address¿¡ Offset Address¸¦ ´õÇÏ¿© Linear Address·Î ÀüȯµÈ´Ù. 286ÀÇ °æ¿ì¿Í mechanismÀº µ¿ÀÏÇÏ´Ù.
- 16bit Segment Selector´Â ÇØ´ç Segment Selector Register (CS, DS, SS, ES, FS, GS)ÀÇ ³»¿ëÀ» ¸»Çϸç, 32bit offsetÀº »ç¿ëÀÚ Á¢±Ù °¡´É Register(EIP, EAX, EBX, ECX, EDX, ESP, EBP, ESI, EDI)¿¡ ±× Á¤º¸°¡ º¸À¯µÇ¸ç, Code SegmentÀÇ °æ¿ì´Â EIP°¡ offsetÀÌ µÈ´Ù.
- SegmentÀÇ Base Address´Â Segment Selector°¡ ÁöÁ¤ÇÏ´Â LDT ¶Ç´Â GDT ³»ÀÇ Segment Descriptor¿¡ ±â¼úµÈ´Ù.
- Segment Descriptor
i286 Segment Descriptor¿¡¼ ¿¹¾àµÈ »óÀ§ 2¹ÙÀÌÆ®ÀÇ Çü½ÄÀÌ Ãß°¡ °áÁ¤µÈ Á¡ ¿Ü¿¡ i286°ú µ¿ÀÏÇÏ´Ù.
|
¡¡ |
Bit |
|||||
|
Segment Base(D24 - D31) |
7 |
|||||
|
G |
X(*) |
0 |
AVL |
Segment Limit(D16-D19) |
6 |
|
|
P |
DPL |
S |
TYPE |
A |
5 |
|
|
Segment Base(D16 - D23) |
4 |
|||||
|
Segment Base(D8 - D15) |
3 |
|||||
|
Segment Base(D0 - D7) |
2 |
|||||
|
Segment Limit(D8 - D15) |
1 |
|||||
|
Segment Limit(D0 - D7) |
0 |
|||||
| Fig- A.20(a) 80386 Segment Descriptor ±¸Á¶ | ¡¡ | |||||
1-3.11 Paging ÁÖ¼Ò º¯È¯ mechanism
- 'Offset'Àº ÇØ´ç Page³»ÀÇ Offset Address¸¦ ³ªÅ¸³½´Ù. offsetÀº Å©±â°¡ 12 bitsÀÓÀ¸·Î PageÀÇ Å©±â°¡ 4K ÀÌ´Ù.
- Page Table ±¸¼ºÀº µÎ ´Ü°è·Î µÇ¾î ÀÖÀ¸¸ç, ù´Ü°è´Â Page Address Table(Page Directory), ´ÙÀ½ ´Ü°è´Â PageTable·Î ±¸¼ºµÈ´Ù. Page Address TableÀÇ Base Address´Â CR3 Control RegisterÀÇ PDBR(Page Directory Base Register)¿¡ ±â·ÏµÇ¾î ÀÖ´Ù.
- 'Directory'´Â Page Address Table¿¡¼ ÇØ´ç Page TableÀÇ Base Address°¡ µé¾î ÀÖ´Â Page Address Table entry¸¦ °¡¸®Å°´Â Offset Address°¡ ±â·ÏµÇ¾î ÀÖ´Ù.
- 'Table'¿¡´Â Page Table ³»¿¡ ÇØ´ç PageÀÇ Base Address°¡ µé¾î ÀÖ´Â Page Table entry¸¦ °¡¸®Å°´Â Offset Address°¡ ±â·ÏµÇ¾î ÀÖ´Ù.
- Page Address Table ¹× Page TableÀÇ entryÀÇ Çü½ÄÀº Page Address TableÀÇ °æ¿ì, Dirty bit¸¦ °¡ÁöÁö ¾Ê´Â´Ù´Â Á¡À» Á¦¿ÜÇϰí´Â µ¿ÀÏÇÏ´Ù. ±× Çü½ÄÀº ´ÙÀ½°ú °°´Ù.
- i386¿¡¼´Â PCD¿Í PWT°¡ °¢°¢ 0À¸·Î setµÇ¾î ÀÖ´Ù.
- P : Memory ³»¿¡ Page Á¸Àç
- U/S : 1·Î setµÈ °æ¿ì, »ç¿ëÀÚ -modeÀ̸ç, ÀÌ´Â Segmentation ModelÀÇ Protection Level 3°ú °°°í, 0À¸·Î setµÈ °æ¿ì, Supervisor-modeÀ̸ç, Segmentation ModelÀÇ Protection Level 0, 1, 2 À̸ç O/S ¿¡ ÇÒ´çµÈ´Ù.
- A, D : 'A' bit´Â Page ¶Ç´Â Page TableÀÌ ÀÐÇû°Å³ª ¾²ÀÎ °æ¿ì¿¡ À̸¦ º¸°íÇϱâ À§ÇØ »ç¿ëµÇ¸ç, 'D' bit´Â PageÀÇ ¾²±â°¡ ÀÌ·ç¾îÁø °æ¿ì¸¦ º¸°íÇϱâ À§ÇØ »ç¿ëµÈ´Ù.
2. Paging ÁÖ¼Ò º¯È¯ mechanismÀº ´ÙÀ½°ú °°´Ù.
3. Translation Lookaside Buffer¿¡´Â ÃÖ±Ù »ç¿ëµÈ Page Table entryµéÀÌ Cache µÇ¾î ÀÖ´Ù(32°³±îÁö °¡´É).
1-3.12 Combining Segment and Page Translation
1- Segmentation°ú PagingÀÌ °áÇÕµÈ ÁÖ¼Ò º¯È¯ mechanismÀº ´ÙÀ½ Fig-°ú °°ÀÌ Á¤¸®µÈ´Ù.
- ÇöÀçÀÇ Task°¡ ´Ù¸¥ TaskÀÇ TSS Descriptor·ÎÀÇ JMP ¶Ç´Â CALL ¸í·É ¼öÇà½Ã
- ÇöÀçÀÇ Task°¡ Task Gate·ÎÀÇ JMP ¶Ç´Â CALL ¸í·É ¼öÇà½Ã
- Interrupt³ª ¿¹¿Ü°¡ IDT¿¡ ÀÖ´Â Task Gate¸¦ ÂüÁ¶ÇÒ ¶§. ¸¸¾à ¿¹¿Ü³ª Interrupt°¡ IDTÀÇ Interrupt Gate³ª Æ®·¦ Gate¸¦ ÂüÁ¶ÇÏ´Â °æ¿ì¿¡´Â Task ÀüȯÀº ¾ø´Ù.
- NT Flag°¡ setµÈ °æ¿ì, ÇöÀç Task°¡ IRET¸¦ ¼öÇàÇÏ´Â °æ¿ì
- Task Àüȯ Çã¿ëÀÌ °¡´ÉÇÑÁö üũ.
- ¿¡·¯ ¹ß»ý À¯¹ß ¸í·É ½ÇÇà ½Ã¿¡ º¯°æµÈ Status ÀúÀå
- ÇöÀç Task Status(Processor Register Statusµé) ÀúÀå
- TR Register ÀûÀç, »õ TaskÀÇ Busy bit set, CR0 RegisterÀÇ TS-bit set. TS-bit´Â ÄÚProcessorÀÇ ³»¿ëÀÌ ÇöÀç Task¿Í´Â ´Ù¸¦ ¼ö ÀÖ´Ù´Â °ÍÀ» ³ªÅ¸³½´Ù.
- TSS·ÎºÎÅÍ »õ TaskÀÇ Status ÀûÀç ¹× ¼öÇà ½ÃÀÛ
¡¡
1-3.14 Multitasking Áö¿ø ÀڷᱸÁ¶
- Task State Segment
- Task ¼öÇàÀ» º¹±Í½Ã۴µ¥ ÇÊ¿äÇÑ Processor StatusÁ¤º¸¸¦ Æ÷ÇÔÇÑ´Ù.
- TSSÀÇ Çü½ÄÀº ´ÙÀ½°ú °°´Ù.
- TSS field´Â Å©°Ô Task Àüȯ½Ã¸¶´Ù °³¼±µÇ´Â µ¿Àû ºÎºÐ°ú °íÁ¤ ºÎºÐÀ¸·Î ºÐ·ùµÈ´Ù.
2. TSS Descriptor
- TSS Descriptor·ÎÀÇ Á¢±ÙÇÏ´Â Procedure´Â Task ÀüȯÀ» ÀÌ·é´Ù.
- TSS Descriptor´Â GDT¿¡ Á¸ÀçÇϸé, ±× Çü½ÄÀº ´ÙÀ½°ú °°´Ù.
3. Task Register
- TR(Task Register)Àº ÇöÀç TSS¸¦ ¹ß°ßÇϴµ¥ »ç¿ëÇÏ´Â °ÍÀ¸·Î, GDT ³»ÀÇ TSS Descriptor À§Ä¡Á¤º¸¸¦ º¸À¯ÇÑ´Ù.
4. Task Gate Descriptor
- Task Gate Descriptor´Â TaskÀÇ °£Á¢ÀûÀÌ¸ç º¸È£µÈ ÂüÁ¶ Á¦°øÇϸç, LDT ¶Ç´Â IDT¿¡ Á¸ÀçÇϸç, ±× Çü½ÄÀº ´ÙÀ½°ú °°´Ù.
![]()
- Task Gate·ÎÀÇ Jump³ª CallÀ» ÅëÇØ °£Á¢ÀûÀ¸·Î Task ÀüȯÀ» ÀÌ·ê ¼ö ÀÖÀ¸¸ç, ÀÌ °æ¿ìÀÇ mechanismÀº ´ÙÀ½ Fig-°ú °°´Ù.
![]()
- Interrupt³ª ¿¹¿Ü°¡ Task ÀüȯÀ» À¯µµÇÒ Çʿ䰡 ÀÖÀ¸¸ç, ÀÌ °æ¿ì IDT ³»¿¡ Task Gate¸¦ »ç¿ëÇÔÀ¸·Î½á Task ÀüȯÀ» À¯µµÇÒ ¼ö ÀÖ´Ù.
5 Task Address Space
- TSSÀÇ LDT Selector¿Í PDBR(CR3) field°¡ °¢°¢ÀÇ Task¿¡ °¢°¢ÀÇ LST¿Í Page TableÀ» Á¦°øÇϴµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù.
- ¿©·¯ Task°¡ °°Àº LDTÀ» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.
- Task ÁÖ¼Ò °ø°£ÀÇ °øÀ¯´Â ´ÙÀ½ Fig-À» ÂüÁ¶Ç϶ó.
Microsoft (R) Macro Assembler Version 5.104/10/2
1 PAGE 120,200
2
3 .386P
4 ; REF : The Intel Microprocessor P633
5
6 0000 DATA Segment AT0000H
7 0000 ORG 0000H
8 ;===============================================
9 ; First 32bit Interrupt Table
10 ;-----------------------------------------------
11 0100 ORG 0100H
12
13 ;===============================================
14 ; Global Segment Descriptor
15 ;-----------------------------------------------
16 ; GDT
17 0100 0000000000000000 DES0DQ0 ; Null Descriptor
18
19 ;===============================================
20 ; Code Segment Descriptor
21 ;-----------------------------------------------
22 0108 FFFF DES1: DW 0FFFFH ; Limit 4GB
23 010A 0000 DW 0 ; Base Address = 0000000H
24 010C 00 DB 0
25 010D 9E DB 10011110B ; 9EH Code Segment
26 010E 8F DB 8FH ; G=1
27 010F 00 DB 0
28 ;===============================================
29 ; Data Segment Descriptor
30 ;-----------------------------------------------
31 0110 FFFF DES2: DW 0FFFFH ; Limit 4GB
32 0112 0000 DW 0 ; Base Address = 0000000H
33 0114 00 DB 0
34 0115 92 DB 10010010B ; 92H Data Segment
35 0116 8F DB 8FH ; G=1
36 0117 00 DB 0
37 ;===============================================
38 ; IDT Table Data
39 ;-----------------------------------------------
0
1 0118 00FF IDT DW 0FFH ; Set Limit to FFH
2 011A 0000000000000000 DQ 0 ; Base Address 0H
43
44 ;===============================================
45 ; GDT Table Data
46 ;-----------------------------------------------
47
48 0122 0017 GDT DW 017H ; Set Limit to 17H
49 0124 0001000000000000 DQ 100H ; Base Address 100H
50 012C DATA ENDS
51
52 ;===============================================
53
54 ;-----------------------------------------------
55 0000 CODE Segment USE16
56 Assume CS:CODE, DS:DATA
57 0000 B8 ---- R START: MOV AX,DATA ; Load DS
58 0003 8E D8 MOV DS,AX
59 0005 67| 0F 01 1D 00000118 LIDT fword ptr IDT ; Load IDTR
60 R
61 000D 67| 0F 01 15 00000122 LGDT fword ptr GDT ; Load GDTR
62 R
63 0015 0F 20 C0 MOV EAX, CR0
64 0018 0C 01 OR AL,1 ; Set PE
65 001A 0F 22 C0 MOV CR0, EAX
66 001D EB 01 90 JMP START1 ; Near jump
67 0020 START1:
68 0020 B8 0010 MOV AX,10H ; Selector 2
69 0023 8E D8 MOV DS,AX
70 0025 8E C0 MOV ES,AX
71 0027 8E D0 MOV SS,AX
72 0029 8E E0 MOV FS,AX
73 002B 8E E8 MOV GS,AX
74 002D 66| BC FFFFFFFF MOV ESP,0FFFFFFFFH
75
76 0033 CODE ENDS
77 END START
Microsoft (R) Macro Assembler Version 5.104/10/2
Symbols-1
Segments and Groups:
N a m e Size LengthAlign Combine Class
CODE . . . . . . . . . . . . . . 16 Bit 0033 PARA NONE
DATA . . . . . . . . . . . . . . 32 Bit 012C AT0000
Symbols:
N a m e Type Value Attr
DES0 . . . . . . . . . . . . . . L QWORD 0100 DATA
DES1 . . . . . . . . . . . . . . L NEAR 0108 DATA
DES2 . . . . . . . . . . . . . . L NEAR 0110 DATA
GDT . . . . . . . . . . . . . . L WORD 0122 DATA
ID T . . . . . . . . . . . . . . L WORD 0118 DATA
START . . . . . . . . . . . . . L NEAR 0000 CODE
START1 . . . . . . . . . . . . . L NEAR 0020 CODE
@CPU . . . . . . . . . . . . . . TEXT 3471
@FILENAME . . . . . . . . . . . TEXT protect
@VERSION . . . . . . . . . . . . TEXT 510
1. Overview
- Hardware´Â RegisterÀÇ °¡»ó¼ÂÆ®(Virtual Set)(TSS¸¦ ÅëÇØ)¿Í °¡»ó Memory °ø°£(Task ¼±Çü°ø°£ÀÇ Ã¹ 1MBytes)À» Á¦°øÇϸç, ÀÌ·¯ÇÑ Register¿Í ÁÖ¼Ò°ø°£À» ´Ù·ç´Â ¸ðµç ¸í·ÉÀ» Á÷Á¢ ¼öÇàÇÑ´Ù.
- Software´Â °¡»ó ¸Ó½ÅÀÇ ¿ÜºÎ Interface(I/O, Interrupt, ¿¹¿Ü)¸¦ º¸´Ù Å« ȯ°æ°ú ÀϰüµÈ ¹æ¹ýÀ¸·Î Á¦¾îÇÑ´Ù. I/OÀÇ °æ¿ì, Software´Â I/O ¸í·ÉÀ» emulateÇϰųª Hardware°¡ Á÷Á¢ SoftwareÀÇ °³ÀÔ ¾øÀÌ ¼öÇàÇϵµ·Ï ÇÑ´Ù.
- Task Àüȯ½Ã EFLAGS°¡ »õ TaskÀÇ TSS·ÎºÎÅÍ »õ·Î ÀûÀçµÇ´Âµ¥, À̶§ VM Flag°¡ setµÈ °æ¿ì
- Procedure·ÎºÎÅÍ IRET´Â StackÀ¸·ÎºÎÅÍ EFLAGS Register°¡ ÀûÀçµÈ´Ù. ÀÌ ¶§, VM Flag°¡ setµÈ °æ¿ì. IRET ¸í·É¼öÇà½Ã CPLÀº 0À̾î¾ß ÇÑ´Ù.
- Segment Register°¡ ÀûÀçµÉ ¶§, i8086ŸÀÔÀÇ ÁÖ¼Òº¯È¯À» »ç¿ëÇØ¾ß Çϴ°¡¸¦ ¾Ë°íÀÚ Çϱâ À§ÇÏ¿©
- ¸í·ÉÀ» ÇØ¼®ÇÒ ¶§, ¾î¶² ¸í·ÉÀÌ IOPL(EFLAGS¿¡ Á¸Àç)¿¡ ¿µÇâÀ» ¹Þ´ÂÁö, ¶ÇÇÑ ¾î¶² ¸í·ÉÀÌ Áö¿øµÇÁö ¾Ê´ÂÁö¸¦ °áÁ¤Çϱâ À§ÇØ
¡¡
2. VM-86ÀÇ Memory °ü¸®
VM-86ÀÇ ÁÖ¼Ò ÁöÁ¤Àº ±âº»ÀûÀ¸·Î Real-mode¿Í PagingÀÇ °áÇÕÀ¸·Î ÀÌ·ç¾îÁø´Ù.
- VM-86ÀÇ ³í¸®ÁÖ¼Ò´Â Real-mode¿Í °°ÀÌ Segment¿Í offsetÀ¸·Î ±¸¼ºµÇ¸ç, SegmentÀÇ °ªÀÌ ¿ÞÂÊÀ¸·Î 4-bit À̵¿µÈ °ª¿¡ offset °ªÀ» ´õÇØ ³ª¿Â °ªÀÌ Linear Address°¡ µÈ´Ù. Real-mode¿¡¼´Â ÀÌ Linear Address°¡ ¹Ù·Î Physical Address°¡ µÇ³ª, VM-86¿¡¼´Â PagingÀ» ÀÌ¿ëÇØ ÀÌ Linear Address°¡ Physical Address·Î º¯È¯µÈ´Ù.
- Paging fault ¹ß»ý½Ã¿¡ VM-86´Â Ring-0ÀÇ Protected-mode·Î ÀÚµ¿ º¯È¯µÇ¾î Protected-mode¿¡¼¿Í °°Àº Page fault Handler°¡ ó¸®ÇÑ´Ù.
3. VM-86ÀÇ Interrupt ó¸®
- Interrupt³ª ¿¹¿Ü°¡ ¹ß»ý½Ã¿¡ VM-86¿¡¼ÀÇ Protected-mode·Î ÀüȯÀÌ ÀÌ·ç¾îÁö´Âµ¥ ´ÙÀ½ÀÇ 2°¡Áö °æ¿ìÀÌ´Ù.
- Interrupt³ª ¿¹¿Ü¹ß»ýÀÌ Task ÀüȯÀ» ÃÊ·¡ÇÏ¿©, À̶§ ÀûÀçµÇ´Â TSSÀÇ EFLAGSÀÇ VM field°¡ clear µÈ °æ¿ì
- Interrupt³ª ¿¹¿Ü°¡ Ư±ÇLevel 0 ÀÎ Procedure¸¦ È£ÃâÇÏ´Â °æ¿ì.
- VM-86¿¡¼ Interrupt ¹ß»ý ½Ã¿¡´Â Ring-0 Stack¿¡ GS, FS, DS, ES µîÀÇ ³»¿ëÀ» ÀúÀåÇϰí À̵é Segment Register ³»¿ëÀ» ¸ðµÎ 0À¸·Î setÇÑ´Ù. ÀÌÈÄ SS, ESP, EFLAGS, CS, EIP¸¦ Ring-0 Stack¿¡ ÀúÀåÇÑ´Ù.
¡¡
4. V86 -mode I/O Interface
- VM-86¿¡¼ I/O ÁÖ¼Ò °ø°£ ÂüÁ¶½Ã IOPLÀÌ Á¡°ËµÇÁö ¾ÊÀ¸¸ç, ´Ù¸¸ I/O Permission Bit Map¸¸ Á¡°ËµÈ´Ù.
- µû¶ó¼, ÀÌ °æ¿ì I/O Çã¿ë-bit mapÀÇ ¼³°è·Î ¿¹¿Ü¸¦ ¹ß»ý½ÃÄÑ, I/O ÁÖ¼Ò°ø°£ÀÇ °¡»óȰ¡ °¡´ÉÇÏ´Ù.
- Memory mapµå I/O¿¡¼´Â Paging mechanismÀ¸·Î I/O Á¦¾î¸¦ ¼öÇàÇÑ´Ù.
- °¢ TaskÀÇ Linear Address °ø°£À» °¢±â ´Ù¸¥ Physical Address °ø°£À¸·Î mappingÇÏ¿© °¢ TaskÀÇ I/O ÀÛ¾÷À» ºÐ¸®ÇÒ ¼ö ÀÖ´Ù.
- °¢ TaskÀÇ Linear Address °ø°£À» Á¸ÀçÇÏÁö ¾Ê´Â Page·Î mapping ½ÃÄÑ, Page fault¸¦ ¹ß»ý½ÃÄÑ I/O¸¦ °¡»óÈ ÇÒ ¼ö ÀÖ´Ù.
5. V86 TaskÀÇ ±¸Á¶
V86 Task´Â i8086 Program°ú Intel Processor(386 ÀÌ»ó) °íÀ¯ CodeÀÎ Virtual-Machine Monitor·Î ±¸¼ºµÇ¸ç, ÀÌ V86 Task´Â TSS·Î Ç¥ÇöµÇ¾î¾ß ÇÑ´Ù.
- Processor´Â i8086 ProgramÀ» ¼öÇàÇϱâ À§ÇØ VM-86 Status·Î µ¿ÀÛÇÏ´Ù°¡ monitor³ª ´Ù¸¥ Task¸¦ ¼öÇàÇϱâ À§ÇØ Protected-mode·Î º¹±ÍÇÑ´Ù.
- VM-86·Î ¼öÇàµÇ±â À§ÇØ, i8086 ProgramÀº V86 Monitor¿Í OS System service°¡ ÇÊ¿äÇÏ´Ù.
V86 Monitor´Â Ư±Ç Level 0À¸·Î ¼öÇàµÇ´Â Protected-mode CodeÀ̸ç, ÀÌ CodeÀÇ Code Segment Descriptor´Â GDT³ª TaskÀÇ LDT¿¡ À§Ä¡ÇÏ¿©¾ß¸¸ ÇÑ´Ù. Monitor¿¡°Ô´Â 1Mbyte ÀÌ»óÀÇ °ø°£ ¶ÇÇÑ ÁÖ¼ÒÁöÁ¤(Addressing)ÀÌ °¡´ÉÇϸç, monitor´Â Interrupt Vector TableÀÌ i8086 ProgramÀÇ ´Ù¸¥ ºÎºÐ °Ë»ç¸¦ À§ÇØ Data Segment Descriptor ¶ÇÇÑ ÇÊ¿äÇÏ´Ù.
![]()
- PagingÀº ´ÜÀÏ V86 Task¿¡´Â ºÒÇÊ¿äÇϳª ´ÙÀ½ÀÇ °æ¿ì¿¡´Â ÇÊ¿äÇÏ´Ù.
- ´ÙÁß V86 Task »ý¼º½Ã. ÀÌ °æ¿ì, Linear Address°ø°£ÀÇ ÇÏÀ§ 1MBÀÇ ÁÖ¼Ò¸¦ °®´Â V86 TaskÀÇ ÁÖ¼Ò °ø°£À» °¢±â ´Ù¸¥ Physical Address°ø°£À¸·Î º¯È¯ÇØ¾ß Çϱ⠶§¹®¿¡ PagingÀÌ ÇÊ¿äÇÏ´Ù.
- Address Wraparound¸¦ emulateÇÒ ¶§.
- Physical Address °ø°£º¸´Ù Å« °¡»ó ÁÖ¼Ò °ø°£À» »ý¼ºÇÒ Çʿ䰡 ÀÖÀ» ¶§
- Multitasking µÇ´Â ¿©·¯ °³ÀÇ i8086 Program¿¡ °øÅëÀÎ i8086 OS
- ROM Code¸¦ °øÀ¯ÇÒ ¶§.
- Memory mapping µÈ I/O Device¿¡ ´ëÇÑ ÂüÁ¶¸¦ RedirectionÇϰųª TrappingÇÒ ¶§.