Changeset 99c2c69e in mainline for kernel/arch/ia32/src/ddi/ddi.c
- Timestamp:
- 2013-09-13T00:36:30Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67fbd5e
- Parents:
- 7f84430 (diff), 11d41be5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/ddi/ddi.c
r7f84430 r99c2c69e 59 59 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) 60 60 { 61 size_t bits = ioaddr + size;62 if ( bits > IO_PORTS)61 size_t elements = ioaddr + size; 62 if (elements > IO_PORTS) 63 63 return ENOENT; 64 64 65 if (task->arch.iomap. bits < bits) {65 if (task->arch.iomap.elements < elements) { 66 66 /* 67 67 * The I/O permission bitmap is too small and needs to be grown. 68 68 */ 69 69 70 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);71 if (! newmap)70 void *store = malloc(bitmap_size(elements), FRAME_ATOMIC); 71 if (!store) 72 72 return ENOMEM; 73 73 74 74 bitmap_t oldiomap; 75 bitmap_initialize(&oldiomap, task->arch.iomap. map,75 bitmap_initialize(&oldiomap, task->arch.iomap.elements, 76 76 task->arch.iomap.bits); 77 bitmap_initialize(&task->arch.iomap, newmap, bits); 77 78 bitmap_initialize(&task->arch.iomap, elements, store); 78 79 79 80 /* 80 81 * Mark the new range inaccessible. 81 82 */ 82 bitmap_set_range(&task->arch.iomap, oldiomap. bits,83 bits - oldiomap.bits);83 bitmap_set_range(&task->arch.iomap, oldiomap.elements, 84 elements - oldiomap.elements); 84 85 85 86 /* … … 89 90 if (oldiomap.bits) { 90 91 bitmap_copy(&task->arch.iomap, &oldiomap, 91 oldiomap.bits); 92 free(oldiomap.map); 92 oldiomap.elements); 93 94 free(oldiomap.bits); 93 95 } 94 96 } … … 97 99 * Enable the range and we are done. 98 100 */ 99 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t)size);101 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size); 100 102 101 103 /* … … 119 121 /* First, copy the I/O Permission Bitmap. */ 120 122 irq_spinlock_lock(&TASK->lock, false); 123 121 124 size_t ver = TASK->arch.iomapver; 122 size_t bits = TASK->arch.iomap.bits; 123 if (bits) { 124 ASSERT(TASK->arch.iomap.map); 125 size_t elements = TASK->arch.iomap.elements; 126 127 if (elements > 0) { 128 ASSERT(TASK->arch.iomap.bits); 125 129 126 130 bitmap_t iomap; 127 bitmap_initialize(&iomap, CPU->arch.tss->iomap,128 TSS_IOMAP_SIZE * 8);129 bitmap_copy(&iomap, &TASK->arch.iomap, bits);131 bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8, 132 CPU->arch.tss->iomap); 133 bitmap_copy(&iomap, &TASK->arch.iomap, elements); 130 134 131 135 /* … … 133 137 * I/O access. 134 138 */ 135 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 139 bitmap_set_range(&iomap, elements, 140 ALIGN_UP(elements, 8) - elements); 141 136 142 /* 137 143 * It is safe to set the trailing eight bits because of the 138 144 * extra convenience byte in TSS_IOMAP_SIZE. 139 145 */ 140 bitmap_set_range(&iomap, ALIGN_UP( bits, 8), 8);146 bitmap_set_range(&iomap, ALIGN_UP(elements, 8), 8); 141 147 } 148 142 149 irq_spinlock_unlock(&TASK->lock, false); 143 150 … … 150 157 151 158 descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base; 152 gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits)); 159 size_t size = bitmap_size(elements); 160 gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size); 153 161 gdtr_load(&cpugdtr); 154 162
Note:
See TracChangeset
for help on using the changeset viewer.