Changeset 1433ecda in mainline for kernel/arch/ia32
- Timestamp:
- 2018-04-04T15:42:37Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2c4e1cc
- Parents:
- 47b2d7e3
- Location:
- kernel/arch/ia32
- Files:
-
- 13 edited
-
include/arch/atomic.h (modified) (6 diffs)
-
include/arch/barrier.h (modified) (2 diffs)
-
include/arch/cpuid.h (modified) (2 diffs)
-
include/arch/cycle.h (modified) (1 diff)
-
include/arch/mm/page.h (modified) (1 diff)
-
include/arch/pm.h (modified) (2 diffs)
-
include/arch/smp/apic.h (modified) (16 diffs)
-
include/arch/smp/mps.h (modified) (7 diffs)
-
src/fpu_context.c (modified) (5 diffs)
-
src/interrupt.c (modified) (2 diffs)
-
src/mm/frame.c (modified) (1 diff)
-
src/smp/apic.c (modified) (1 diff)
-
src/smp/mps.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/include/arch/atomic.h
r47b2d7e3 r1433ecda 46 46 #ifdef CONFIG_SMP 47 47 asm volatile ( 48 "lock incl %[count]\n"49 : [count] "+m" (val->count)50 ); 51 #else 52 asm volatile ( 53 "incl %[count]\n"54 : [count] "+m" (val->count)48 "lock incl %[count]\n" 49 : [count] "+m" (val->count) 50 ); 51 #else 52 asm volatile ( 53 "incl %[count]\n" 54 : [count] "+m" (val->count) 55 55 ); 56 56 #endif /* CONFIG_SMP */ … … 61 61 #ifdef CONFIG_SMP 62 62 asm volatile ( 63 "lock decl %[count]\n"64 : [count] "+m" (val->count)65 ); 66 #else 67 asm volatile ( 68 "decl %[count]\n"69 : [count] "+m" (val->count)63 "lock decl %[count]\n" 64 : [count] "+m" (val->count) 65 ); 66 #else 67 asm volatile ( 68 "decl %[count]\n" 69 : [count] "+m" (val->count) 70 70 ); 71 71 #endif /* CONFIG_SMP */ … … 77 77 78 78 asm volatile ( 79 "lock xaddl %[r], %[count]\n"80 : [count] "+m" (val->count),81 [r] "+r" (r)79 "lock xaddl %[r], %[count]\n" 80 : [count] "+m" (val->count), 81 [r] "+r" (r) 82 82 ); 83 83 … … 90 90 91 91 asm volatile ( 92 "lock xaddl %[r], %[count]\n"93 : [count] "+m" (val->count),94 [r] "+r" (r)92 "lock xaddl %[r], %[count]\n" 93 : [count] "+m" (val->count), 94 [r] "+r" (r) 95 95 ); 96 96 … … 106 106 107 107 asm volatile ( 108 "xchgl %[v], %[count]\n"109 : [v] "+r" (v),110 [count] "+m" (val->count)108 "xchgl %[v], %[count]\n" 109 : [v] "+r" (v), 110 [count] "+m" (val->count) 111 111 ); 112 112 … … 122 122 preemption_disable(); 123 123 asm volatile ( 124 "0:\n"124 "0:\n" 125 125 #ifndef PROCESSOR_i486 126 "pause\n" /* Pentium 4's HT love this instruction */127 #endif 128 "mov %[count], %[tmp]\n"129 "testl %[tmp], %[tmp]\n"130 "jnz 0b\n" /* lightweight looping on locked spinlock */131 132 "incl %[tmp]\n" /* now use the atomic operation */133 "xchgl %[count], %[tmp]\n"134 "testl %[tmp], %[tmp]\n"135 "jnz 0b\n"136 : [count] "+m" (val->count),137 [tmp] "=&r" (tmp)126 "pause\n" /* Pentium 4's HT love this instruction */ 127 #endif 128 "mov %[count], %[tmp]\n" 129 "testl %[tmp], %[tmp]\n" 130 "jnz 0b\n" /* lightweight looping on locked spinlock */ 131 132 "incl %[tmp]\n" /* now use the atomic operation */ 133 "xchgl %[count], %[tmp]\n" 134 "testl %[tmp], %[tmp]\n" 135 "jnz 0b\n" 136 : [count] "+m" (val->count), 137 [tmp] "=&r" (tmp) 138 138 ); 139 139 -
kernel/arch/ia32/include/arch/barrier.h
r47b2d7e3 r1433ecda 56 56 #ifndef __PIC__ 57 57 asm volatile ( 58 "xorl %%eax, %%eax\n"59 "cpuid\n"60 ::: "eax", "ebx", "ecx", "edx", "memory"58 "xorl %%eax, %%eax\n" 59 "cpuid\n" 60 ::: "eax", "ebx", "ecx", "edx", "memory" 61 61 ); 62 62 #else 63 63 /* Must not clobber PIC register ebx */ 64 64 asm volatile ( 65 "movl %%ebx, %%esi\n"66 "xorl %%eax, %%eax\n"67 "cpuid\n"68 "movl %%esi, %%ebx\n"69 ::: "eax", "ecx", "edx", "esi", "memory"65 "movl %%ebx, %%esi\n" 66 "xorl %%eax, %%eax\n" 67 "cpuid\n" 68 "movl %%esi, %%ebx\n" 69 ::: "eax", "ecx", "edx", "esi", "memory" 70 70 ); 71 71 #endif … … 73 73 74 74 #if defined(CONFIG_FENCES_P4) 75 #define memory_barrier() asm volatile ("mfence\n" ::: "memory")76 #define read_barrier() asm volatile ("lfence\n" ::: "memory")77 #ifdef CONFIG_WEAK_MEMORY78 #define write_barrier() asm volatile ("sfence\n" ::: "memory")79 #else80 #define write_barrier() asm volatile ("" ::: "memory");81 #endif75 #define memory_barrier() asm volatile ("mfence\n" ::: "memory") 76 #define read_barrier() asm volatile ("lfence\n" ::: "memory") 77 #ifdef CONFIG_WEAK_MEMORY 78 #define write_barrier() asm volatile ("sfence\n" ::: "memory") 79 #else 80 #define write_barrier() asm volatile ("" ::: "memory"); 81 #endif 82 82 #elif defined(CONFIG_FENCES_P3) 83 #define memory_barrier() cpuid_serialization() 84 #define read_barrier() cpuid_serialization() 85 #ifdef CONFIG_WEAK_MEMORY 86 #define write_barrier() asm volatile ("sfence\n" ::: "memory") 87 #else 88 #define write_barrier() asm volatile ("" ::: "memory"); 89 #endif 83 #define memory_barrier() cpuid_serialization() 84 #define read_barrier() cpuid_serialization() 85 #ifdef CONFIG_WEAK_MEMORY 86 #define write_barrier() asm volatile ("sfence\n" ::: "memory") 90 87 #else 91 #define memory_barrier() cpuid_serialization() 92 #define read_barrier() cpuid_serialization() 93 #ifdef CONFIG_WEAK_MEMORY 94 #define write_barrier() cpuid_serialization() 95 #else 96 #define write_barrier() asm volatile ("" ::: "memory"); 97 #endif 88 #define write_barrier() asm volatile ("" ::: "memory"); 89 #endif 90 #else 91 #define memory_barrier() cpuid_serialization() 92 #define read_barrier() cpuid_serialization() 93 #ifdef CONFIG_WEAK_MEMORY 94 #define write_barrier() cpuid_serialization() 95 #else 96 #define write_barrier() asm volatile ("" ::: "memory"); 97 #endif 98 98 #endif 99 99 -
kernel/arch/ia32/include/arch/cpuid.h
r47b2d7e3 r1433ecda 85 85 86 86 asm volatile ( 87 "pushf\n" /* read flags */88 "popl %[ret]\n"89 "movl %[ret], %[val]\n"87 "pushf\n" /* read flags */ 88 "popl %[ret]\n" 89 "movl %[ret], %[val]\n" 90 90 91 "xorl %[eflags_id], %[val]\n" /* swap the ID bit */91 "xorl %[eflags_id], %[val]\n" /* swap the ID bit */ 92 92 93 "pushl %[val]\n" /* propagate the change into flags */94 "popf\n"95 "pushf\n"96 "popl %[val]\n"93 "pushl %[val]\n" /* propagate the change into flags */ 94 "popf\n" 95 "pushf\n" 96 "popl %[val]\n" 97 97 98 "andl %[eflags_id], %[ret]\n" /* interrested only in ID bit */99 "andl %[eflags_id], %[val]\n"100 "xorl %[val], %[ret]\n"101 : [ret] "=r" (ret), [val] "=r" (val)102 : [eflags_id] "i" (EFLAGS_ID)98 "andl %[eflags_id], %[ret]\n" /* interrested only in ID bit */ 99 "andl %[eflags_id], %[val]\n" 100 "xorl %[val], %[ret]\n" 101 : [ret] "=r" (ret), [val] "=r" (val) 102 : [eflags_id] "i" (EFLAGS_ID) 103 103 ); 104 104 … … 109 109 { 110 110 asm volatile ( 111 "cpuid\n"112 : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx),113 "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx)114 : "a" (cmd)111 "cpuid\n" 112 : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx), 113 "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx) 114 : "a" (cmd) 115 115 ); 116 116 } -
kernel/arch/ia32/include/arch/cycle.h
r47b2d7e3 r1433ecda 45 45 uint64_t v; 46 46 47 asm volatile (48 "rdtsc\n"49 : "=A" (v)47 asm volatile ( 48 "rdtsc\n" 49 : "=A" (v) 50 50 ); 51 51 -
kernel/arch/ia32/include/arch/mm/page.h
r47b2d7e3 r1433ecda 178 178 unsigned avl : 2; 179 179 unsigned frame_address : 20; 180 } __attribute__ ((packed)) pte_t;180 } __attribute__((packed)) pte_t; 181 181 182 182 NO_TRACE static inline unsigned int get_pt_flags(pte_t *pt, size_t i) -
kernel/arch/ia32/include/arch/pm.h
r47b2d7e3 r1433ecda 89 89 uint16_t limit; 90 90 uint32_t base; 91 } __attribute__ ((packed)) ptr_16_32_t;91 } __attribute__((packed)) ptr_16_32_t; 92 92 93 93 typedef struct { 94 unsigned limit_0_15 : 16;95 unsigned base_0_15 : 16;96 unsigned base_16_23 : 8;97 unsigned access : 8;98 unsigned limit_16_19 : 4;99 unsigned available : 1;100 unsigned unused : 1;101 unsigned special : 1;94 unsigned limit_0_15 : 16; 95 unsigned base_0_15 : 16; 96 unsigned base_16_23 : 8; 97 unsigned access : 8; 98 unsigned limit_16_19 : 4; 99 unsigned available : 1; 100 unsigned unused : 1; 101 unsigned special : 1; 102 102 unsigned granularity : 1; 103 unsigned base_24_31 : 8;104 } __attribute__ ((packed)) descriptor_t;103 unsigned base_24_31 : 8; 104 } __attribute__((packed)) descriptor_t; 105 105 106 106 typedef struct { 107 unsigned offset_0_15 : 16;108 unsigned selector : 16;109 unsigned unused : 8;110 unsigned access : 8;111 unsigned offset_16_31 : 16;112 } __attribute__ ((packed)) idescriptor_t;107 unsigned offset_0_15 : 16; 108 unsigned selector : 16; 109 unsigned unused : 8; 110 unsigned access : 8; 111 unsigned offset_16_31 : 16; 112 } __attribute__((packed)) idescriptor_t; 113 113 114 114 typedef struct { … … 152 152 uint16_t iomap_base; 153 153 uint8_t iomap[TSS_IOMAP_SIZE]; 154 } __attribute__ ((packed)) tss_t;154 } __attribute__((packed)) tss_t; 155 155 156 156 extern ptr_16_32_t gdtr; -
kernel/arch/ia32/include/arch/smp/apic.h
r47b2d7e3 r1433ecda 128 128 unsigned int shorthand : 2; /**< Destination Shorthand. */ 129 129 unsigned int : 12; /**< Reserved. */ 130 } __attribute__ ((packed));130 } __attribute__((packed)); 131 131 }; 132 132 union { … … 135 135 unsigned int : 24; /**< Reserved. */ 136 136 uint8_t dest; /**< Destination field. */ 137 } __attribute__ ((packed));137 } __attribute__((packed)); 138 138 }; 139 } __attribute__ ((packed)) icr_t;139 } __attribute__((packed)) icr_t; 140 140 141 141 /* End Of Interrupt. */ … … 158 158 unsigned int illegal_register_address : 1; 159 159 unsigned int : 24; 160 } __attribute__ ((packed));160 } __attribute__((packed)); 161 161 } esr_t; 162 162 … … 169 169 unsigned int pri_sc : 4; /**< Task Priority Sub-Class. */ 170 170 unsigned int pri : 4; /**< Task Priority. */ 171 } __attribute__ ((packed));171 } __attribute__((packed)); 172 172 } tpr_t; 173 173 … … 182 182 unsigned int focus_checking : 1; /**< Focus Processor Checking. */ 183 183 unsigned int : 22; /**< Reserved. */ 184 } __attribute__ ((packed));184 } __attribute__((packed)); 185 185 } svr_t; 186 186 … … 193 193 unsigned int div_value : 4; /**< Divide Value, bit 2 is always 0. */ 194 194 unsigned int : 28; /**< Reserved. */ 195 } __attribute__ ((packed));195 } __attribute__((packed)); 196 196 } tdcr_t; 197 197 … … 215 215 unsigned int mode : 1; /**< Timer Mode. */ 216 216 unsigned int : 14; /**< Reserved. */ 217 } __attribute__ ((packed));217 } __attribute__((packed)); 218 218 } lvt_tm_t; 219 219 … … 234 234 unsigned int masked : 1; /**< Interrupt Mask. */ 235 235 unsigned int : 15; /**< Reserved. */ 236 } __attribute__ ((packed));236 } __attribute__((packed)); 237 237 } lvt_lint_t; 238 238 … … 249 249 unsigned int masked : 1; /**< Interrupt Mask. */ 250 250 unsigned int : 15; /**< Reserved. */ 251 } __attribute__ ((packed));251 } __attribute__((packed)); 252 252 } lvt_error_t; 253 253 … … 260 260 unsigned int : 24; /**< Reserved. */ 261 261 uint8_t apic_id; /**< Local APIC ID. */ 262 } __attribute__ ((packed));262 } __attribute__((packed)); 263 263 } l_apic_id_t; 264 264 … … 279 279 unsigned int : 24; /**< Reserved. */ 280 280 uint8_t id; /**< Logical APIC ID. */ 281 } __attribute__ ((packed));281 } __attribute__((packed)); 282 282 } ldr_t; 283 283 … … 290 290 unsigned int : 28; /**< Reserved, all ones. */ 291 291 unsigned int model : 4; /**< Model. */ 292 } __attribute__ ((packed));292 } __attribute__((packed)); 293 293 } dfr_t; 294 294 … … 308 308 uint8_t reg_addr; /**< APIC Register Address. */ 309 309 unsigned int : 24; /**< Reserved. */ 310 } __attribute__ ((packed));310 } __attribute__((packed)); 311 311 } io_regsel_t; 312 312 … … 325 325 unsigned int masked : 1; /**< Interrupt Mask. */ 326 326 unsigned int : 15; /**< Reserved. */ 327 } __attribute__ ((packed));327 } __attribute__((packed)); 328 328 }; 329 329 union { … … 332 332 unsigned int : 24; /**< Reserved. */ 333 333 uint8_t dest : 8; /**< Destination Field. */ 334 } __attribute__ ((packed));334 } __attribute__((packed)); 335 335 }; 336 336 337 } __attribute__ ((packed)) io_redirection_reg_t;337 } __attribute__((packed)) io_redirection_reg_t; 338 338 339 339 … … 345 345 unsigned int apic_id : 4; /**< IO APIC ID. */ 346 346 unsigned int : 4; /**< Reserved. */ 347 } __attribute__ ((packed));347 } __attribute__((packed)); 348 348 } io_apic_id_t; 349 349 -
kernel/arch/ia32/include/arch/smp/mps.h
r47b2d7e3 r1433ecda 55 55 uint8_t mpfib4; 56 56 uint8_t mpfib5; 57 } __attribute__ ((packed));57 } __attribute__((packed)); 58 58 59 59 struct mps_ct { … … 72 72 uint8_t reserved; 73 73 uint8_t base_table[0]; 74 } __attribute__ ((packed));74 } __attribute__((packed)); 75 75 76 76 struct __processor_entry { … … 82 82 uint32_t feature_flags; 83 83 uint32_t reserved[2]; 84 } __attribute__ ((packed));84 } __attribute__((packed)); 85 85 86 86 struct __bus_entry { … … 88 88 uint8_t bus_id; 89 89 uint8_t bus_type[6]; 90 } __attribute__ ((packed));90 } __attribute__((packed)); 91 91 92 92 struct __io_apic_entry { … … 96 96 uint8_t io_apic_flags; 97 97 uint32_t io_apic; 98 } __attribute__ ((packed));98 } __attribute__((packed)); 99 99 100 100 struct __io_intr_entry { … … 107 107 uint8_t dst_io_apic_id; 108 108 uint8_t dst_io_apic_pin; 109 } __attribute__ ((packed));109 } __attribute__((packed)); 110 110 111 111 struct __l_intr_entry { … … 118 118 uint8_t dst_l_apic_id; 119 119 uint8_t dst_l_apic_pin; 120 } __attribute__ ((packed));120 } __attribute__((packed)); 121 121 122 122 extern struct smp_config_operations mps_config_operations; -
kernel/arch/ia32/src/fpu_context.c
r47b2d7e3 r1433ecda 71 71 { 72 72 asm volatile ( 73 "fnsave %[fctx]"74 : [fctx] "=m" (fctx->fpu)73 "fnsave %[fctx]" 74 : [fctx] "=m" (fctx->fpu) 75 75 ); 76 76 } … … 79 79 { 80 80 asm volatile ( 81 "frstor %[fctx]"82 : [fctx] "=m" (fctx->fpu)81 "frstor %[fctx]" 82 : [fctx] "=m" (fctx->fpu) 83 83 ); 84 84 } … … 87 87 { 88 88 asm volatile ( 89 "fxsave %[fctx]"90 : [fctx] "=m" (fctx->fpu)89 "fxsave %[fctx]" 90 : [fctx] "=m" (fctx->fpu) 91 91 ); 92 92 } … … 95 95 { 96 96 asm volatile ( 97 "fxrstor %[fctx]"98 : [fctx] "=m" (fctx->fpu)97 "fxrstor %[fctx]" 98 : [fctx] "=m" (fctx->fpu) 99 99 ); 100 100 } … … 131 131 132 132 asm volatile ( 133 "fninit\n"134 "stmxcsr %[help0]\n"135 "mov %[help0], %[help1]\n"136 "or %[magic], %[help1]\n"137 "mov %[help1], %[help0]\n"138 "ldmxcsr %[help0]\n"139 : [help0] "+m" (help0), [help1] "+r" (help1)140 : [magic] "i" (X87_ALL_MASK)133 "fninit\n" 134 "stmxcsr %[help0]\n" 135 "mov %[help0], %[help1]\n" 136 "or %[magic], %[help1]\n" 137 "mov %[help1], %[help0]\n" 138 "ldmxcsr %[help0]\n" 139 : [help0] "+m" (help0), [help1] "+r" (help1) 140 : [magic] "i" (X87_ALL_MASK) 141 141 ); 142 142 } -
kernel/arch/ia32/src/interrupt.c
r47b2d7e3 r1433ecda 62 62 */ 63 63 64 void (* disable_irqs_function)(uint16_t irqmask) = NULL;65 void (* enable_irqs_function)(uint16_t irqmask) = NULL;66 void (* eoi_function)(void) = NULL;64 void (*disable_irqs_function)(uint16_t irqmask) = NULL; 65 void (*enable_irqs_function)(uint16_t irqmask) = NULL; 66 void (*eoi_function)(void) = NULL; 67 67 const char *irqs_info = NULL; 68 68 … … 146 146 uint32_t mxcsr; 147 147 asm volatile ( 148 "stmxcsr %[mxcsr]\n"149 : [mxcsr] "=m" (mxcsr)148 "stmxcsr %[mxcsr]\n" 149 : [mxcsr] "=m" (mxcsr) 150 150 ); 151 151 -
kernel/arch/ia32/src/mm/frame.c
r47b2d7e3 r1433ecda 142 142 name = "invalid"; 143 143 144 printf("%#018" PRIx64 " %#018" PRIx64 " %s\n", e820table[i].base_address,144 printf("%#018" PRIx64 " %#018" PRIx64 " %s\n", e820table[i].base_address, 145 145 e820table[i].size, name); 146 146 } -
kernel/arch/ia32/src/smp/apic.c
r47b2d7e3 r1433ecda 482 482 l_apic[ICRT] = 0xffffffff; 483 483 484 while (l_apic[CCRT] == t1); 484 while (l_apic[CCRT] == t1) 485 ; 485 486 486 487 t1 = l_apic[CCRT]; -
kernel/arch/ia32/src/smp/mps.c
r47b2d7e3 r1433ecda 257 257 } 258 258 259 log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8 " pin=%"259 log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8 " pin=%" 260 260 PRIu8, iointr->src_bus_id, iointr->src_bus_irq, 261 261 iointr->dst_io_apic_id, iointr->dst_io_apic_pin); … … 320 320 } 321 321 322 log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8 " pin=%"322 log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8 " pin=%" 323 323 PRIu8, lintr->src_bus_id, lintr->src_bus_irq, 324 324 lintr->dst_l_apic_id, lintr->dst_l_apic_pin);
Note:
See TracChangeset
for help on using the changeset viewer.
