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