xref: /minix3/minix/include/arch/i386/include/memory.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1 /* Physical memory layout on IBM compatible PCs. Only the major, fixed memory
2  * areas are detailed here. Known addresses of the BIOS data area are defined
3  * in <ibm/bios.h>. The map upper memory area (UMA) is only roughly defined
4  * since the UMA sections may vary in size and locus.
5  *
6  * Created: March 2005, Jorrit N. Herder
7  */
8 
9 /* I/O-mapped peripherals. I/O addresses are different from memory addresses
10  * due to the I/O signal on the ISA bus. Individual I/O ports are defined by
11  * the drivers that use them or looked up with help of the BIOS.
12  */
13 #define IO_MEMORY_BEGIN             0x0000
14 #define IO_MEMORY_END               0xFFFF
15 
16 
17 /* Physical memory layout. Design decisions made for the earliest PCs, caused
18  * memory to be broken broken into the following four basic pieces:
19  *  - Conventional or base memory: first 640 KB (incl. BIOS data, see below);
20  *    The top of conventional memory is often used by the BIOS to store data.
21  *  - Upper Memory Area (UMA): upper 384 KB of the first megabyte of memory;
22  *  - High Memory Area (HMA): ~ first 64 KB of the second megabyte of memory;
23  *  - Extended Memory: all the memory above first megabyte of memory.
24  * The high memory area overlaps with the first 64 KB of extended memory, but
25  * is different from the rest of extended memory because it can be accessed
26  * when the processor is in real mode.
27  */
28 #define BASE_MEM_BEGIN            0x000000
29 #define BASE_MEM_TOP		  0x090000
30 #define BASE_MEM_END              0x09FFFF
31 
32 #define UPPER_MEM_BEGIN           0x0A0000
33 #define UPPER_MEM_END             0x0FFFFF
34 
35 #define HIGH_MEM_BEGIN            0x100000
36 #define HIGH_MEM_END              0x10FFEF
37 
38 #define EXTENDED_MEM_BEGIN        0x100000
39 #define EXTENDED_MEM_END    ((unsigned) -1)
40 
41 
42 /* The logical memory map of the first 1.5 MB is as follows (hexadecimals):
43  *
44  * offset [size]  (id) = memory usage
45  * ------------------------------------------------------------------------
46  * 000000 [00400] (I) = Real-Mode Interrupt Vector Table (1024 B)
47  * 000400 [00100] (B) = BIOS Data Area (256 B)
48  * 000800 [00066] (W) = 80286 Loadall workspace
49  * 010000 [10000] (c) = Real-Mode Compatibility Segment (64 KB)
50  * 020000 [70000] (.) = Program-accessible memory (free)
51  * 090000 [10000] (E) = BIOS Extension
52  * 0A0000 [10000] (G) = Graphics Mode Video RAM
53  * 0B0000 [08000] (M) = Monochrome Text Mode Video RAM
54  * 0B8000 [08000] (C) = Color Text Mode Video RAM
55  * 0C0000 [08000] (V) = Video ROM BIOS (would be "a" in PS/2)
56  * 0C8000 [18000] (a) = Adapter ROM + special-purpose RAM (free UMA space)
57  * 0E0000 [10000] (r) = PS/2 Motherboard ROM BIOS (free UMA in non-PS/2)
58  * 0F0000 [06000] (R) = Motherboard ROM BIOS
59  * 0F6000 [08000] (b) = IBM Cassette BASIC ROM ("R" in IBM compatibles)
60  * 0FD000 [02000] (R) = Motherboard ROM BIOS
61  * 100000 [.....] (.) = Extended memory, program-accessible (free)
62  * 100000 [0FFEF] (h) = High Memory Area (HMA)
63  *
64  *
65  * Conventional (Base) Memory:
66  *
67  *       : [~~~~~16 KB~~~~][~~~~~16 KB~~~~][~~~~~16 KB~~~~][~~~~~16 KB~~~~]
68  *       : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
69  * 000000: IBW.............................................................
70  * 010000: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
71  * 020000: ................................................................
72  * 030000: ................................................................
73  * 040000: ................................................................
74  * 050000: ................................................................
75  * 060000: ................................................................
76  * 070000: ................................................................
77  * 080000: ................................................................
78  * 090000: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
79  *
80  * Upper Memory Area (UMA):
81  *
82  *       : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
83  * 0A0000: GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
84  * 0B0000: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
85  * 0C0000: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
86  * 0D0000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
87  * 0E0000: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
88  * 0F0000: RRRRRRRRRRRRRRRRRRRRRRRRbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbRRRRRRRR
89  *
90  * Extended Memory:
91  *
92  *       : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
93  * 100000: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.
94  * 110000: ................................................................
95  * 120000: ................................................................
96  * 130000: ................................................................
97  * 140000: ................................................................
98  * 150000: ................................................................
99  * 160000: ................................................................
100  * 170000: ................................................................
101  *
102  * Source: The logical memory map was partly taken from the book "Upgrading
103  *         & Repairing PCs Eight Edition", Macmillan Computer Publishing.
104  */
105 
106 
107 /* The bottom part of conventional or base memory is occupied by BIOS data.
108  * The BIOS memory can be distinguished in two parts:
109  * o The first the first 1024 bytes of addressable memory contains the BIOS
110  *   real-mode interrupt vector table (IVT). The table is used to access BIOS
111  *   hardware services in real-mode by loading a interrupt vector and issuing
112  *   an INT instruction. Some vectors contain BIOS data that can be retrieved
113  *   directly and are useful in protected-mode as well.
114  * o The BIOS data area is located directly above the interrupt vectors. It
115  *   comprises 256 bytes of memory. These data are used by the device drivers
116  *   to retrieve hardware details, such as I/O ports to be used.
117  */
118 #define BIOS_MEM_BEGIN             0x00000      /* all BIOS memory */
119 #define BIOS_MEM_END               0x004FF
120 #define   BIOS_IVT_BEGIN           0x00000      /* BIOS interrupt vectors */
121 #define   BIOS_IVT_END             0x003FF
122 #define   BIOS_DATA_BEGIN          0x00400      /* BIOS data area */
123 #define   BIOS_DATA_END            0x004FF
124 
125 /* The base memory is followed by 384 KB reserved memory located at the top of
126  * the first MB of physical memory. This memory is known as the upper memory
127  * area (UMA). It is used for memory-mapped peripherals, such as video RAM,
128  * adapter BIOS (adapter ROM and special purpose RAM), and the motherboard
129  * BIOS (I/O system, Power-On Self Test, bootstrap loader). The upper memory
130  * can roughly be distinguished in three parts:
131  *
132  * o The first 128K of the upper memory area (A0000-BFFFF) is reserved for use
133  *   by memory-mapped video adapters. Hence, it is also called Video RAM. The
134  *   display driver can directly write to this memory and request the hardware
135  *   to show the data on the screen.
136  */
137 #define UMA_VIDEO_RAM_BEGIN        0xA0000      /* video RAM */
138 #define UMA_VIDEO_RAM_END          0xBFFFF
139 #define   UMA_GRAPHICS_RAM_BEGIN   0xA0000      /* graphics RAM */
140 #define   UMA_GRAPHICS_RAM_END     0xAFFFF
141 #define   UMA_MONO_TEXT_BEGIN      0xB0000      /* monochrome text */
142 #define   UMA_MONO_TEXT_END        0xB7FFF
143 #define   UMA_COLOR_TEXT_BEGIN     0xB8000      /* color text */
144 #define   UMA_COLOR_TEXT_END       0xBFFFF
145 
146 /* o The next 128K (the memory range C0000-DFFFF) is reserved for the adapter
147  *   BIOS that resides in the ROM on some adapter boards. Most VGA-compatible
148  *   video adapters use the first 32 KB of this area for their on-board BIOS.
149  *   The rest can be used by any other adapters. The IDE controller often
150  *   occupies the second 32 KB.
151  */
152 #define UMA_ADAPTER_BIOS_BEGIN     0xC0000      /* adapter BIOS */
153 #define UMA_ADAPTER_BIOS_END       0xDFFFF
154 #define   UMA_VIDEO_BIOS_BEGIN     0xC0000      /* video adapter */
155 #define   UMA_VIDEO_BIOS_END       0xC7FFF
156 #define   UMA_IDE_HD_BIOS_BEGIN    0xC8000      /* IDE hard disk */
157 #define   UMA_IDE_HD_BIOS_END      0xCBFFF
158 
159 /* o The last 128K of the upper memory area (E0000-FFFFF) is reserved for
160  *   motherboard BIOS (Basic I/O System). The POST (Power-On Self Test) and
161  *   bootstrap loader also reside in  this space. The memory falls apart in
162  *   two areas: Plug & Play BIOS data and the system BIOS data.
163  */
164 #define UMA_MB_BIOS_BEGIN          0xE0000      /* motherboard BIOS */
165 #define UMA_MB_BIOS_END            0xFFFFF
166 #define   UMA_PNP_ESCD_BIOS_BEGIN  0xE0000      /* PnP extended data */
167 #define   UMA_PNP_ESCD_BIOS_END    0xEFFFF
168 #define   UMA_SYSTEM_BIOS_BEGIN    0xF0000      /* system BIOS */
169 #define   UMA_SYSTEM_BIOS_END      0xFFFFF
170 
171 
172