Changes in kernel/arch/amd64/src/ddi/ddi.c [e9e5b9ab:98000fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/ddi/ddi.c
re9e5b9ab r98000fb 36 36 #include <arch/ddi/ddi.h> 37 37 #include <proc/task.h> 38 #include < typedefs.h>38 #include <arch/types.h> 39 39 #include <adt/bitmap.h> 40 40 #include <mm/slab.h> … … 49 49 * Interrupts are disabled and task is locked. 50 50 * 51 * @param task 51 * @param task Task. 52 52 * @param ioaddr Startign I/O space address. 53 * @param size 53 * @param size Size of the enabled I/O range. 54 54 * 55 55 * @return 0 on success or an error code from errno.h. 56 *57 56 */ 58 57 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) 59 58 { 60 size_t bits = ioaddr + size; 59 size_t bits; 60 61 bits = ioaddr + size; 61 62 if (bits > IO_PORTS) 62 63 return ENOENT; 63 64 64 65 if (task->arch.iomap.bits < bits) { 66 bitmap_t oldiomap; 67 uint8_t *newmap; 68 65 69 /* 66 70 * The I/O permission bitmap is too small and needs to be grown. 67 71 */ 68 72 69 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);73 newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC); 70 74 if (!newmap) 71 75 return ENOMEM; 72 76 73 bitmap_t oldiomap;74 77 bitmap_initialize(&oldiomap, task->arch.iomap.map, 75 78 task->arch.iomap.bits); … … 112 115 * 113 116 * Interrupts must be disabled prior this call. 114 *115 117 */ 116 118 void io_perm_bitmap_install(void) 117 119 { 120 size_t bits; 121 ptr_16_64_t cpugdtr; 122 descriptor_t *gdt_p; 123 tss_descriptor_t *tss_desc; 124 size_t ver; 125 118 126 /* First, copy the I/O Permission Bitmap. */ 119 irq_spinlock_lock(&TASK->lock, false); 120 size_t ver = TASK->arch.iomapver; 121 size_t bits = TASK->arch.iomap.bits; 122 if (bits) { 127 spinlock_lock(&TASK->lock); 128 ver = TASK->arch.iomapver; 129 if ((bits = TASK->arch.iomap.bits)) { 130 bitmap_t iomap; 131 123 132 ASSERT(TASK->arch.iomap.map); 124 125 bitmap_t iomap;126 133 bitmap_initialize(&iomap, CPU->arch.tss->iomap, 127 134 TSS_IOMAP_SIZE * 8); 128 bitmap_copy(&iomap, &TASK->arch.iomap, bits); 129 130 /* 131 * Set the trailing bits in the last byte of the map to disable 132 * I/O access. 133 */ 134 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 135 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits); 135 136 /* 136 137 * It is safe to set the trailing eight bits because of the 137 138 * extra convenience byte in TSS_IOMAP_SIZE. 138 139 */ 139 bitmap_set_range(&iomap, ALIGN_UP( bits, 8), 8);140 bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8); 140 141 } 141 irq_spinlock_unlock(&TASK->lock, false);142 spinlock_unlock(&TASK->lock); 142 143 143 144 /* … … 145 146 * Take the extra ending byte will all bits set into account. 146 147 */ 147 ptr_16_64_t cpugdtr;148 148 gdtr_store(&cpugdtr); 149 150 descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base; 149 gdt_p = (descriptor_t *) cpugdtr.base; 151 150 gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits)); 152 151 gdtr_load(&cpugdtr); … … 156 155 * type must be changed to describe inactive TSS. 157 156 */ 158 tss_desc riptor_t *tss_desc= (tss_descriptor_t *) &gdt_p[TSS_DES];157 tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES]; 159 158 tss_desc->type = AR_TSS; 160 tr_load( GDT_SELECTOR(TSS_DES));159 tr_load(gdtselector(TSS_DES)); 161 160 162 161 /*
Note:
See TracChangeset
for help on using the changeset viewer.