Changeset e49e234 in mainline for kernel/arch/ia32
- Timestamp:
- 2009-02-27T11:32:31Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1f7f6ea
- Parents:
- 5f0f29ce
- Location:
- kernel/arch/ia32
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/include/boot/memmap.h
r5f0f29ce re49e234 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_MEMMAP_H_ 37 37 38 /* E820h memory range types - other values*/ 39 /* Free memory */ 40 #define MEMMAP_MEMORY_AVAILABLE 1 41 /* Not available for OS */ 42 #define MEMMAP_MEMORY_RESERVED 2 43 /* OS may use it after reading ACPI table */ 44 #define MEMMAP_MEMORY_ACPI 3 45 /* Unusable, required to be saved and restored across an NVS sleep */ 46 #define MEMMAP_MEMORY_NVS 4 47 /* Corrupted memory */ 48 #define MEMMAP_MEMORY_UNUSABLE 5 38 /* E820h memory range types */ 49 39 50 /* size of one entry */ 51 #define MEMMAP_E820_RECORD_SIZE 20 52 /* maximum entries */ 53 #define MEMMAP_E820_MAX_RECORDS 32 40 /* Free memory */ 41 #define MEMMAP_MEMORY_AVAILABLE 1 54 42 43 /* Not available for OS */ 44 #define MEMMAP_MEMORY_RESERVED 2 45 46 /* OS may use it after reading ACPI table */ 47 #define MEMMAP_MEMORY_ACPI 3 48 49 /* Unusable, required to be saved and restored across an NVS sleep */ 50 #define MEMMAP_MEMORY_NVS 4 51 52 /* Corrupted memory */ 53 #define MEMMAP_MEMORY_UNUSABLE 5 54 55 /* Size of one entry */ 56 #define MEMMAP_E820_RECORD_SIZE 20 57 58 /* Maximum entries */ 59 #define MEMMAP_E820_MAX_RECORDS 32 55 60 56 61 #ifndef __ASM__ -
kernel/arch/ia32/include/mm/frame.h
r5f0f29ce re49e234 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_FRAME_H_ 37 37 38 #define FRAME_WIDTH 12/* 4K */39 #define FRAME_SIZE 38 #define FRAME_WIDTH 12 /* 4K */ 39 #define FRAME_SIZE (1 << FRAME_WIDTH) 40 40 41 41 #ifdef KERNEL … … 45 45 46 46 extern uintptr_t last_frame; 47 extern uintptr_t end_frame;48 47 49 48 extern void frame_arch_init(void); -
kernel/arch/ia32/src/mm/frame.c
r5f0f29ce re49e234 51 51 52 52 uintptr_t last_frame = 0; 53 uintptr_t end_frame = 0;54 53 55 54 static void init_e820_memory(pfn_t minconf) 56 55 { 57 56 unsigned int i; 58 pfn_t start, conf;59 size_t size;60 61 57 for (i = 0; i < e820counter; i++) { 58 uint64_t base = e820table[i].base_address; 59 uint64_t size = e820table[i].size; 60 61 #ifdef __32_BITS__ 62 63 /* Ignore physical memory above 4 GB */ 64 if ((base >> 32) != 0) 65 continue; 66 67 /* Clip regions above 4 GB */ 68 if (((base + size) >> 32) != 0) 69 size = 0xffffffff - base; 70 71 #endif 72 pfn_t pfn; 73 count_t count; 74 62 75 if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { 63 start = ADDR2PFN(ALIGN_UP(e820table[i].base_address, FRAME_SIZE)); 64 size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size, FRAME_SIZE)); 76 /* To be safe, make available zone possibly smaller */ 77 pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE)); 78 count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)); 65 79 66 if ((minconf < start) || (minconf >= start + size)) 67 conf = start; 80 pfn_t conf; 81 if ((minconf < pfn) || (minconf >= pfn + count)) 82 conf = pfn; 68 83 else 69 84 conf = minconf; 70 85 71 zone_create( start, size, conf, 0);86 zone_create(pfn, count, conf, ZONE_AVAILABLE); 72 87 73 if (last_frame < ALIGN_UP(e820table[i].base_address + 74 e820table[i].size, FRAME_SIZE)) 75 last_frame = 76 ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE); 88 // XXX this has to be removed 89 if (last_frame < ALIGN_UP(base + size, FRAME_SIZE)) 90 last_frame = ALIGN_UP(base + size, FRAME_SIZE); 91 } 92 93 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) { 94 /* To be safe, make reserved zone possibly larger */ 95 pfn = ADDR2PFN(ALIGN_DOWN(base, FRAME_SIZE)); 96 count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE)); 97 98 zone_create(pfn, count, 0, ZONE_RESERVED); 99 } 100 101 if (e820table[i].type == MEMMAP_MEMORY_ACPI) { 102 /* To be safe, make firmware zone possibly larger */ 103 pfn = ADDR2PFN(ALIGN_DOWN(base, (uintptr_t) FRAME_SIZE)); 104 count = SIZE2FRAMES(ALIGN_UP(size, (uintptr_t) FRAME_SIZE)); 105 106 zone_create(pfn, count, 0, ZONE_FIRMWARE); 77 107 } 78 108 } 79 80 end_frame = last_frame;81 109 } 82 110 -
kernel/arch/ia32/src/mm/page.c
r5f0f29ce re49e234 35 35 #include <arch/mm/page.h> 36 36 #include <genarch/mm/page_pt.h> 37 #include <genarch/drivers/ega/ega.h>38 #include <genarch/drivers/legacy/ia32/io.h>39 37 #include <arch/mm/frame.h> 40 38 #include <mm/frame.h> … … 51 49 #include <print.h> 52 50 #include <interrupt.h> 53 #include <ddi/ddi.h>54 55 /** Physical memory area for devices. */56 static parea_t dev_area;57 static parea_t ega_area;58 51 59 52 void page_arch_init(void) … … 61 54 uintptr_t cur; 62 55 int flags; 63 56 64 57 if (config.cpu_active == 1) { 65 58 page_mapping_operations = &pt_mapping_operations; … … 74 67 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 75 68 } 76 69 77 70 exc_register(14, "page_fault", (iroutine) page_fault); 78 71 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 79 72 } else 80 73 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 81 74 82 75 paging_on(); 83 76 } … … 99 92 100 93 return virtaddr; 101 }102 103 void hw_area(void)104 {105 dev_area.pbase = end_frame;106 dev_area.frames = SIZE2FRAMES(0xffffffff - end_frame);107 ddi_parea_register(&dev_area);108 109 ega_area.pbase = EGA_VIDEORAM;110 ega_area.frames = SIZE2FRAMES(EGA_VRAM_SIZE);111 ddi_parea_register(&ega_area);112 94 } 113 95
Note:
See TracChangeset
for help on using the changeset viewer.