Browse Source

Update memory map and add INT list

Jeremiah Orians 2 years ago
parent
commit
4fec19dd0d
2 changed files with 109 additions and 15 deletions
  1. 1 1
      POSIX
  2. 108 14
      x86/notes.org

+ 1 - 1
POSIX

@@ -1 +1 @@
-Subproject commit a99baf0579a23de7e291116c130f2b02f6029836
+Subproject commit 15a783e18f0f04a1195133f1ae9a3e799ef78ebf

+ 108 - 14
x86/notes.org

@@ -26,27 +26,121 @@ An improved hex/octal assembler that supports labels and calculation of relative
 A Cat equivalent (Because definition files are awesome)
 A Less equivalent (Because you want to be able to just read your written code)
 A line macro program (Because Hex mnemonics suck and ADD32I are a lot easier to identify)
-The stage0-vm in assembly or a compiler/interpreter for the higher language of your choice you plan on leveraging to implement the stage0-vm
+The compiler/interpreter for the higher language of your choice you plan on leveraging
 
 * Platform specific information
 ** 8086
-To encode assembly to hex, please reference: http://ref.x86asm.net/geek.html
+To obtain a good reference for hex encoding of 8088 instructions, get a copy of
+Oscar Toledo Gutierrez's book:
+more boot sector games (If you are experienced in assembly)
+or
+programming boot sector games (If you need to learn assembly first)
+
 WARNING encoding is an extremely slow and painful process by hand,
 BE VERY VERY THANKFUL for those that came before us and made such wonderful
 things as assemblers and C compilers that hide most of the horrible darkness from our eyes...
 
 *** Default memory map
-| 16-bit mem map (seg:off)       | What is there                 |
-|--------------------------------+-------------------------------|
-| 0x0000:0x0000 -> 0x0000:0x0500 | BIOS stuff                    |
-| 0x0000:0x0500 -> 0x0000:0x2100 | root                          |
-| 0x0000:0x2100 -> 0x0000:0x3300 | fat                           |
-| 0x0000:0x3300 -> 0x0000:0x6c00 | 14,25kb free space            |
-| 0x0000:0x6c00 -> 0x0000:0x7c00 | IDT and GDT (256 desc. eatch) |
-| 0x0000:0x7c00 -> 0x0000:0x7e00 | bootsector                    |
-| 0x0000:0x7e00 <- 0x0000:0xffff | ~32,5kb stack for boot        |
-| 0x1000:0x0000 -> 0x9000:0xffff | 576kb free space              |
-| 0xa000:0x0000 -> ............. | VGA mem etc.                  |
+| 16-bit mem map (seg:off)       | What is there          |
+|--------------------------------+------------------------|
+| 0x0000:0x0000 -> 0x0000:0x03FF | Interrupt Vectors      |
+| 0x0000:0x0400 -> 0x0000:0x79FF | Stack space            |
+| 0x0000:0x7a00 -> 0x0000:0x7BFF | BootstrapOS            |
+| 0x0000:0x7c00 -> 0x9000:0xFFFF | 640KB of Base RAM      |
+| 0xa000:0x0000 -> 0xa000:0xFFFF | EGA/VGA graphics modes |
+| 0xb000:0x0000 -> 0xb000:0x7FFF | Monochrome text mode   |
+| 0xb000:0x8000 -> 0xb000:0xFFFF | Color Text mode        |
+| 0xc000:0x0000 -> 0xd000:0xFFFF | Video card ROM         |
+| 0xd000:0x0000 -> 0xe000:0xFFFF | Reserved for ROMs      |
+| 0xf000:0x0000 -> 0xf000:0xFFFF | BIOS ROM               |
+
+The MBR is loaded into memory at address 0x0000:0x7C00
+and its last 2 bytes must be: 0x55 and 0xAA
+
+*** Segment registers
+| name | function               |
+|------+------------------------|
+| cs   | Segment code is in     |
+| ds   | Segment data is in     |
+| es   | Segment strings are in |
+| ss   | Segment stack is in    |
+
+Any instruction can be prefixed by cs, ds, es or ss to change which segment
+register is used by the instruction at the cost of an additional byte of for the
+instruction encoding.
+
+*** Interrupts
+Use a 256 entry table of 32bit words with a corresponding index to the interrupt number.
+Each entry is made of 2 16bit values:
+Target IP:Target CS (Code segment)
+Which then pushes the flags register, then the caller's CS register and then the
+caller's IP Then the IP and CS are loaded into their corresponding registers and
+the processor jumps to address CS:IP which must be in the first 1MB of memory
+
+After completing its work, the function called must use iret to return to the
+caller and reset the flags register.
+
+**** Standard Table
+|   Number | Description                                          |
+|----------+------------------------------------------------------|
+|        0 | CPU divide by zero                                   |
+|        1 | Debug single step                                    |
+|        2 | Non Maskable Interrupt (NMI input on processor)      |
+|        3 | Debug breakpoints                                    |
+|        4 | Arithmetic overflow                                  |
+|        5 | BIOS provided Print Screen routine                   |
+|   6 -> 7 | Reserved                                             |
+|        8 | IRQ0, Time of day hardware services                  |
+|        9 | IRQ1, Keyboard Interface                             |
+|        A | IRQ2, ISA Bus cascade services for second 8259       |
+|        B | IRQ3, Com 2 hardware                                 |
+|        C | IRQ4, Com1 hardware                                  |
+|        D | IRQ5, LPT2, Parallel port hardware (Hard Disk on XT) |
+|        E | IRQ6, Floppy Disk adaptor                            |
+|        F | IRQ7, LPT1, Parallel port hardware                   |
+|       10 | Video services                                       |
+|       11 | Equipment check                                      |
+|       12 | Memory size determination                            |
+|       13 | Floppy I/O routines                                  |
+|       14 | Serial port I/O routines                             |
+|       15 | PC used for Cassette tape services                   |
+|       16 | Keyboard I/O routines                                |
+|       17 | Printer I/O routines                                 |
+|       18 | Points to basic interpreter in a "real" IBM PC       |
+|       19 | Bootstrap loader                                     |
+|       1A | Time of day services                                 |
+|       1B | Services Ctrl-Break service                          |
+|       1C | Timer tick (provides 18.2 ticks per second)          |
+|       1D | Video parameters                                     |
+|       1E | Disk parameters                                      |
+|       1F | Video graphics                                       |
+|       20 | Program termination                                  |
+|       21 | All DOS services available through this Interrupt    |
+|       22 | Terminate address                                    |
+|       23 | Ctrl-Break exit address                              |
+|       24 | Critical error handler                               |
+|       25 | Read logical sectors                                 |
+|       26 | Write logical sectors                                |
+|       27 | Terminate and stay resident routines (obsolete)      |
+| 28 -> 3F | Reserved for DOS                                     |
+| 40 -> 50 | Reserved for BIOS                                    |
+|       51 | Mouse functions                                      |
+| 52 -> 5F | Reserved for BIOS                                    |
+| 60 -> 66 | Reserved for User programs                           |
+|       67 | Used for EMS functions                               |
+| 68 -> 6F | Unused                                               |
+|       70 | IRQ8, ISA bus Real time clock                        |
+|       71 | IRQ9, takes the place of IRQ2                        |
+|       72 | IRQ10 (available hardware interrupt)                 |
+|       73 | IRQ11 (available hardware interrupt)                 |
+|       74 | IRQ12 (available hardware interrupt)                 |
+|       75 | IRQ13, maths co-processor                            |
+|       76 | IRQ14, ISA bus hard disk controller                  |
+|       77 | IRQ15, (available hardware interrupt)                |
+| 78 -> 7F | Unused                                               |
+| 80 -> 85 | Reserved for basic                                   |
+| 86 -> F0 | Used by basic                                        |
+| F1 -> FF | Unused                                               |
 
 *** Restart code
 To restart the segment loaded from the bootsector:
@@ -60,7 +154,7 @@ For an intersegment restart:
 |--------+---------------------|
 | 6A00   | push 0              |
 | 68007C | push 7C00           |
-| CF     | iret                |
+| CB     | retf                |
 
 * Testing notes
 ** Making blank floppy disk images