Changes in kernel/arch/amd64/src/ddi/ddi.c [1d3d2cf:d99c1d2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/ddi/ddi.c
r1d3d2cf rd99c1d2 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 135 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits); 129 130 136 /* 131 137 * It is safe to set the trailing eight bits because of the … … 134 140 bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8); 135 141 } 136 irq_spinlock_unlock(&TASK->lock, false);142 spinlock_unlock(&TASK->lock); 137 143 138 144 /* … … 140 146 * Take the extra ending byte will all bits set into account. 141 147 */ 142 ptr_16_64_t cpugdtr;143 148 gdtr_store(&cpugdtr); 144 145 descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base; 149 gdt_p = (descriptor_t *) cpugdtr.base; 146 150 gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits)); 147 151 gdtr_load(&cpugdtr); … … 151 155 * type must be changed to describe inactive TSS. 152 156 */ 153 tss_desc riptor_t *tss_desc= (tss_descriptor_t *) &gdt_p[TSS_DES];157 tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES]; 154 158 tss_desc->type = AR_TSS; 155 tr_load( GDT_SELECTOR(TSS_DES));159 tr_load(gdtselector(TSS_DES)); 156 160 157 161 /*
Note:
See TracChangeset
for help on using the changeset viewer.