Changeset 04803bf in mainline for kernel/arch/ia32/include
- Timestamp:
- 2011-03-21T22:00:17Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (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. - Location:
- kernel/arch/ia32/include
- Files:
-
- 31 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/include/asm.h
rb50b5af2 r04803bf 38 38 39 39 #include <arch/pm.h> 40 #include <arch/ types.h>40 #include <arch/cpu.h> 41 41 #include <typedefs.h> 42 42 #include <config.h> 43 44 extern uint32_t interrupt_handler_size; 45 46 extern void paging_on(void); 47 48 extern void interrupt_handlers(void); 49 50 extern void enable_l_apic_in_msr(void); 51 52 53 extern void asm_delay_loop(uint32_t t); 54 extern void asm_fake_loop(uint32_t t); 55 43 #include <trace.h> 56 44 57 45 /** Halt CPU … … 60 48 * 61 49 */ 62 static inline void cpu_halt(void) 63 { 64 asm volatile ( 65 "0:\n" 66 " hlt\n" 67 " jmp 0b\n" 68 ); 69 } 70 71 static inline void cpu_sleep(void) 72 { 73 asm volatile ("hlt\n"); 74 } 75 76 #define GEN_READ_REG(reg) static inline unative_t read_ ##reg (void) \ 50 NO_TRACE static inline __attribute__((noreturn)) void cpu_halt(void) 51 { 52 while (true) { 53 asm volatile ( 54 "hlt\n" 55 ); 56 } 57 } 58 59 NO_TRACE static inline void cpu_sleep(void) 60 { 61 asm volatile ( 62 "hlt\n" 63 ); 64 } 65 66 #define GEN_READ_REG(reg) NO_TRACE static inline sysarg_t read_ ##reg (void) \ 77 67 { \ 78 unative_t res; \68 sysarg_t res; \ 79 69 asm volatile ( \ 80 70 "movl %%" #reg ", %[res]" \ … … 84 74 } 85 75 86 #define GEN_WRITE_REG(reg) static inline void write_ ##reg (unative_t regn) \76 #define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (sysarg_t regn) \ 87 77 { \ 88 78 asm volatile ( \ … … 119 109 * 120 110 */ 121 static inline void pio_write_8(ioport8_t *port, uint8_t val)111 NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t val) 122 112 { 123 113 asm volatile ( 124 114 "outb %b[val], %w[port]\n" 125 :: [val] "a" (val), [port] "d" (port) 115 :: [val] "a" (val), 116 [port] "d" (port) 126 117 ); 127 118 } … … 135 126 * 136 127 */ 137 static inline void pio_write_16(ioport16_t *port, uint16_t val)128 NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t val) 138 129 { 139 130 asm volatile ( 140 131 "outw %w[val], %w[port]\n" 141 :: [val] "a" (val), [port] "d" (port) 132 :: [val] "a" (val), 133 [port] "d" (port) 142 134 ); 143 135 } … … 151 143 * 152 144 */ 153 static inline void pio_write_32(ioport32_t *port, uint32_t val)145 NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t val) 154 146 { 155 147 asm volatile ( 156 148 "outl %[val], %w[port]\n" 157 :: [val] "a" (val), [port] "d" (port) 149 :: [val] "a" (val), 150 [port] "d" (port) 158 151 ); 159 152 } … … 167 160 * 168 161 */ 169 static inline uint8_t pio_read_8(ioport8_t *port)162 NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port) 170 163 { 171 164 uint8_t val; … … 188 181 * 189 182 */ 190 static inline uint16_t pio_read_16(ioport16_t *port)183 NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port) 191 184 { 192 185 uint16_t val; … … 209 202 * 210 203 */ 211 static inline uint32_t pio_read_32(ioport32_t *port)204 NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port) 212 205 { 213 206 uint32_t val; … … 230 223 * 231 224 */ 232 static inline ipl_t interrupts_enable(void)225 NO_TRACE static inline ipl_t interrupts_enable(void) 233 226 { 234 227 ipl_t v; … … 252 245 * 253 246 */ 254 static inline ipl_t interrupts_disable(void)247 NO_TRACE static inline ipl_t interrupts_disable(void) 255 248 { 256 249 ipl_t v; … … 273 266 * 274 267 */ 275 static inline void interrupts_restore(ipl_t ipl)268 NO_TRACE static inline void interrupts_restore(ipl_t ipl) 276 269 { 277 270 asm volatile ( … … 287 280 * 288 281 */ 289 static inline ipl_t interrupts_read(void)282 NO_TRACE static inline ipl_t interrupts_read(void) 290 283 { 291 284 ipl_t v; … … 300 293 } 301 294 295 /** Check interrupts state. 296 * 297 * @return True if interrupts are disabled. 298 * 299 */ 300 NO_TRACE static inline bool interrupts_disabled(void) 301 { 302 ipl_t v; 303 304 asm volatile ( 305 "pushf\n" 306 "popl %[v]\n" 307 : [v] "=r" (v) 308 ); 309 310 return ((v & EFLAGS_IF) == 0); 311 } 312 302 313 /** Write to MSR */ 303 static inline void write_msr(uint32_t msr, uint64_t value)314 NO_TRACE static inline void write_msr(uint32_t msr, uint64_t value) 304 315 { 305 316 asm volatile ( 306 317 "wrmsr" 307 :: "c" (msr), "a" ((uint32_t) (value)), 318 :: "c" (msr), 319 "a" ((uint32_t) (value)), 308 320 "d" ((uint32_t) (value >> 32)) 309 321 ); 310 322 } 311 323 312 static inline uint64_t read_msr(uint32_t msr)324 NO_TRACE static inline uint64_t read_msr(uint32_t msr) 313 325 { 314 326 uint32_t ax, dx; … … 316 328 asm volatile ( 317 329 "rdmsr" 318 : "=a" (ax), "=d" (dx) 330 : "=a" (ax), 331 "=d" (dx) 319 332 : "c" (msr) 320 333 ); … … 331 344 * 332 345 */ 333 static inline uintptr_t get_stack_base(void)346 NO_TRACE static inline uintptr_t get_stack_base(void) 334 347 { 335 348 uintptr_t v; … … 344 357 } 345 358 346 /** Return current IP address */347 static inline uintptr_t * get_ip()348 {349 uintptr_t *ip;350 351 asm volatile (352 "mov %%eip, %[ip]"353 : [ip] "=r" (ip)354 );355 356 return ip;357 }358 359 359 /** Invalidate TLB Entry. 360 360 * … … 362 362 * 363 363 */ 364 static inline void invlpg(uintptr_t addr)364 NO_TRACE static inline void invlpg(uintptr_t addr) 365 365 { 366 366 asm volatile ( 367 367 "invlpg %[addr]\n" 368 :: [addr] "m" (*( unative_t *) addr)368 :: [addr] "m" (*(sysarg_t *) addr) 369 369 ); 370 370 } … … 375 375 * 376 376 */ 377 static inline void gdtr_load(ptr_16_32_t *gdtr_reg)377 NO_TRACE static inline void gdtr_load(ptr_16_32_t *gdtr_reg) 378 378 { 379 379 asm volatile ( … … 388 388 * 389 389 */ 390 static inline void gdtr_store(ptr_16_32_t *gdtr_reg)390 NO_TRACE static inline void gdtr_store(ptr_16_32_t *gdtr_reg) 391 391 { 392 392 asm volatile ( 393 393 "sgdtl %[gdtr_reg]\n" 394 : : [gdtr_reg] "m" (*gdtr_reg)394 : [gdtr_reg] "=m" (*gdtr_reg) 395 395 ); 396 396 } … … 401 401 * 402 402 */ 403 static inline void idtr_load(ptr_16_32_t *idtr_reg)403 NO_TRACE static inline void idtr_load(ptr_16_32_t *idtr_reg) 404 404 { 405 405 asm volatile ( … … 414 414 * 415 415 */ 416 static inline void tr_load(uint16_t sel)416 NO_TRACE static inline void tr_load(uint16_t sel) 417 417 { 418 418 asm volatile ( … … 422 422 } 423 423 424 extern void paging_on(void); 425 extern void enable_l_apic_in_msr(void); 426 427 extern void asm_delay_loop(uint32_t); 428 extern void asm_fake_loop(uint32_t); 429 430 extern uintptr_t int_syscall; 431 432 extern uintptr_t int_0; 433 extern uintptr_t int_1; 434 extern uintptr_t int_2; 435 extern uintptr_t int_3; 436 extern uintptr_t int_4; 437 extern uintptr_t int_5; 438 extern uintptr_t int_6; 439 extern uintptr_t int_7; 440 extern uintptr_t int_8; 441 extern uintptr_t int_9; 442 extern uintptr_t int_10; 443 extern uintptr_t int_11; 444 extern uintptr_t int_12; 445 extern uintptr_t int_13; 446 extern uintptr_t int_14; 447 extern uintptr_t int_15; 448 extern uintptr_t int_16; 449 extern uintptr_t int_17; 450 extern uintptr_t int_18; 451 extern uintptr_t int_19; 452 extern uintptr_t int_20; 453 extern uintptr_t int_21; 454 extern uintptr_t int_22; 455 extern uintptr_t int_23; 456 extern uintptr_t int_24; 457 extern uintptr_t int_25; 458 extern uintptr_t int_26; 459 extern uintptr_t int_27; 460 extern uintptr_t int_28; 461 extern uintptr_t int_29; 462 extern uintptr_t int_30; 463 extern uintptr_t int_31; 464 extern uintptr_t int_32; 465 extern uintptr_t int_33; 466 extern uintptr_t int_34; 467 extern uintptr_t int_35; 468 extern uintptr_t int_36; 469 extern uintptr_t int_37; 470 extern uintptr_t int_38; 471 extern uintptr_t int_39; 472 extern uintptr_t int_40; 473 extern uintptr_t int_41; 474 extern uintptr_t int_42; 475 extern uintptr_t int_43; 476 extern uintptr_t int_44; 477 extern uintptr_t int_45; 478 extern uintptr_t int_46; 479 extern uintptr_t int_47; 480 extern uintptr_t int_48; 481 extern uintptr_t int_49; 482 extern uintptr_t int_50; 483 extern uintptr_t int_51; 484 extern uintptr_t int_52; 485 extern uintptr_t int_53; 486 extern uintptr_t int_54; 487 extern uintptr_t int_55; 488 extern uintptr_t int_56; 489 extern uintptr_t int_57; 490 extern uintptr_t int_58; 491 extern uintptr_t int_59; 492 extern uintptr_t int_60; 493 extern uintptr_t int_61; 494 extern uintptr_t int_62; 495 extern uintptr_t int_63; 496 424 497 #endif 425 498 -
kernel/arch/ia32/include/atomic.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_ATOMIC_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <arch/barrier.h> 40 40 #include <preemption.h> 41 #include <trace.h> 41 42 42 static inline void atomic_inc(atomic_t *val) { 43 NO_TRACE static inline void atomic_inc(atomic_t *val) 44 { 43 45 #ifdef CONFIG_SMP 44 46 asm volatile ( … … 54 56 } 55 57 56 static inline void atomic_dec(atomic_t *val) { 58 NO_TRACE static inline void atomic_dec(atomic_t *val) 59 { 57 60 #ifdef CONFIG_SMP 58 61 asm volatile ( … … 68 71 } 69 72 70 static inline long atomic_postinc(atomic_t *val) 73 NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val) 71 74 { 72 longr = 1;75 atomic_count_t r = 1; 73 76 74 77 asm volatile ( 75 78 "lock xaddl %[r], %[count]\n" 76 : [count] "+m" (val->count), [r] "+r" (r) 79 : [count] "+m" (val->count), 80 [r] "+r" (r) 77 81 ); 78 82 … … 80 84 } 81 85 82 static inline long atomic_postdec(atomic_t *val) 86 NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val) 83 87 { 84 longr = -1;88 atomic_count_t r = -1; 85 89 86 90 asm volatile ( 87 91 "lock xaddl %[r], %[count]\n" 88 : [count] "+m" (val->count), [r] "+r"(r) 92 : [count] "+m" (val->count), 93 [r] "+r" (r) 89 94 ); 90 95 … … 95 100 #define atomic_predec(val) (atomic_postdec(val) - 1) 96 101 97 static inline uint32_t test_and_set(atomic_t *val) { 98 uint32_t v; 102 NO_TRACE static inline atomic_count_t test_and_set(atomic_t *val) 103 { 104 atomic_count_t v = 1; 99 105 100 106 asm volatile ( 101 "movl $1, %[v]\n"102 107 "xchgl %[v], %[count]\n" 103 : [v] "=r" (v), [count] "+m" (val->count) 108 : [v] "+r" (v), 109 [count] "+m" (val->count) 104 110 ); 105 111 … … 108 114 109 115 /** ia32 specific fast spinlock */ 110 static inline void atomic_lock_arch(atomic_t *val)116 NO_TRACE static inline void atomic_lock_arch(atomic_t *val) 111 117 { 112 uint32_t tmp;118 atomic_count_t tmp; 113 119 114 120 preemption_disable(); … … 124 130 "testl %[tmp], %[tmp]\n" 125 131 "jnz 0b\n" 126 : [count] "+m" (val->count), [tmp] "=&r" (tmp) 132 : [count] "+m" (val->count), 133 [tmp] "=&r" (tmp) 127 134 ); 135 128 136 /* 129 137 * Prevent critical section code from bleeding out this way up. -
kernel/arch/ia32/include/barrier.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_BARRIER_H_ 37 37 38 #include <trace.h> 39 38 40 /* 39 41 * NOTE: … … 50 52 #define CS_LEAVE_BARRIER() asm volatile ("" ::: "memory") 51 53 52 static inline void cpuid_serialization(void)54 NO_TRACE static inline void cpuid_serialization(void) 53 55 { 54 56 #ifndef __IN_SHARED_LIBC__ -
kernel/arch/ia32/include/bios/bios.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_BIOS_H_ 37 37 38 #include <arch/types.h> 39 40 #define BIOS_EBDA_PTR 0x40e 38 #include <typedefs.h> 41 39 42 40 extern uintptr_t ebda; -
kernel/arch/ia32/include/boot/boot.h
rb50b5af2 r04803bf 38 38 #define BOOT_OFFSET 0x108000 39 39 #define AP_BOOT_OFFSET 0x8000 40 #define BOOT_STACK_SIZE 0x 40040 #define BOOT_STACK_SIZE 0x0400 41 41 42 42 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 -
kernel/arch/ia32/include/boot/memmap.h
rb50b5af2 r04803bf 61 61 #ifndef __ASM__ 62 62 63 #include < arch/types.h>63 #include <typedefs.h> 64 64 65 65 typedef struct { … … 70 70 71 71 extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 72 extern uint8_t e820counter; 72 extern uint8_t e820counter; 73 73 74 74 #endif -
kernel/arch/ia32/include/context.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 37 37 38 38 #ifdef KERNEL 39 #include <arch/types.h>40 39 41 #define STACK_ITEM_SIZE 4 40 #include <typedefs.h> 41 42 #define STACK_ITEM_SIZE 4 42 43 43 44 /* … … 47 48 * One item is put onto stack to support get_stack_base(). 48 49 */ 49 #define SP_DELTA (8 + STACK_ITEM_SIZE) 50 #define SP_DELTA (8 + STACK_ITEM_SIZE) 51 52 #define context_set(c, _pc, stack, size) \ 53 do { \ 54 (c)->pc = (uintptr_t) (_pc); \ 55 (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \ 56 (c)->ebp = 0; \ 57 } while (0) 50 58 51 59 #endif /* KERNEL */ -
kernel/arch/ia32/include/context_offset.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_CONTEXT_OFFSET_H_ 37 37 38 #define OFFSET_SP 0x039 #define OFFSET_PC 0x440 #define OFFSET_EBX 0x841 #define OFFSET_ESI 0xC42 #define OFFSET_EDI 0x1043 #define OFFSET_EBP 0x1438 #define OFFSET_SP 0x00 39 #define OFFSET_PC 0x04 40 #define OFFSET_EBX 0x08 41 #define OFFSET_ESI 0x0C 42 #define OFFSET_EDI 0x10 43 #define OFFSET_EBP 0x14 44 44 45 #ifdef KERNEL 46 # define OFFSET_IPL0x1845 #ifdef KERNEL 46 #define OFFSET_IPL 0x18 47 47 #else 48 # define OFFSET_TLS0x1848 #define OFFSET_TLS 0x18 49 49 #endif 50 50 51 #ifdef __ASM__ 51 52 52 #ifdef __ASM__ 53 54 # ctx: address of the structure with saved context 53 # ctx: address of the structure with saved context 55 54 # pc: return address 56 55 57 56 .macro CONTEXT_SAVE_ARCH_CORE ctx:req pc:req 58 movl %esp,OFFSET_SP(\ctx) # %esp -> ctx->sp 57 movl %esp,OFFSET_SP(\ctx) # %esp -> ctx->sp 59 58 movl \pc,OFFSET_PC(\ctx) # %eip -> ctx->pc 60 movl %ebx,OFFSET_EBX(\ctx) # %ebx -> ctx->ebx 61 movl %esi,OFFSET_ESI(\ctx) # %esi -> ctx->esi 62 movl %edi,OFFSET_EDI(\ctx) # %edi -> ctx->edi 63 movl %ebp,OFFSET_EBP(\ctx) # %ebp -> ctx->ebp 59 movl %ebx,OFFSET_EBX(\ctx) # %ebx -> ctx->ebx 60 movl %esi,OFFSET_ESI(\ctx) # %esi -> ctx->esi 61 movl %edi,OFFSET_EDI(\ctx) # %edi -> ctx->edi 62 movl %ebp,OFFSET_EBP(\ctx) # %ebp -> ctx->ebp 64 63 .endm 65 64 66 # ctx: address of the structure with saved context 65 # ctx: address of the structure with saved context 67 66 68 67 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req pc:req … … 75 74 .endm 76 75 77 #endif /* __ASM__ */ 76 #endif /* __ASM__ */ 78 77 79 78 #endif … … 81 80 /** @} 82 81 */ 83 -
kernel/arch/ia32/include/cpu.h
rb50b5af2 r04803bf 37 37 38 38 #define EFLAGS_IF (1 << 9) 39 #define EFLAGS_DF (1 << 10) 40 #define EFLAGS_NT (1 << 14) 39 41 #define EFLAGS_RF (1 << 16) 40 42 … … 42 44 43 45 /* Support for SYSENTER and SYSEXIT */ 44 #define IA32_MSR_SYSENTER_CS 0x17445 #define IA32_MSR_SYSENTER_ESP 0x17546 #define IA32_MSR_SYSENTER_EIP 0x17646 #define IA32_MSR_SYSENTER_CS 0x174U 47 #define IA32_MSR_SYSENTER_ESP 0x175U 48 #define IA32_MSR_SYSENTER_EIP 0x176U 47 49 48 50 #ifndef __ASM__ … … 50 52 #include <arch/pm.h> 51 53 #include <arch/asm.h> 54 #include <arch/cpuid.h> 52 55 53 56 typedef struct { … … 56 59 unsigned int model; 57 60 unsigned int stepping; 61 cpuid_feature_info fi; 62 58 63 tss_t *tss; 59 64 -
kernel/arch/ia32/include/cpuid.h
rb50b5af2 r04803bf 43 43 #ifndef __ASM__ 44 44 45 #include < arch/types.h>45 #include <typedefs.h> 46 46 47 47 typedef struct { … … 63 63 64 64 struct __cpuid_feature_info { 65 unsigned : 23; 65 unsigned : 11; 66 unsigned sep : 1; 67 unsigned : 11; 66 68 unsigned mmx : 1; 67 69 unsigned fxsr : 1; -
kernel/arch/ia32/include/cycle.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_CYCLE_H_ 37 37 38 static inline uint64_t get_cycle(void) 38 #include <trace.h> 39 40 NO_TRACE static inline uint64_t get_cycle(void) 39 41 { 40 42 uint64_t v; -
kernel/arch/ia32/include/ddi/ddi.h
rb50b5af2 r04803bf 32 32 /** 33 33 * @file 34 * @brief 34 * @brief ia32 specific DDI declarations and macros. 35 35 */ 36 36 -
kernel/arch/ia32/include/drivers/i8254.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_I8254_H_ 37 37 38 #include <arch/types.h>39 40 38 extern void i8254_init(void); 41 39 extern void i8254_calibrate_delay_loop(void); -
kernel/arch/ia32/include/drivers/i8259.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_I8259_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <arch/interrupt.h> 40 40 41 #define PIC_PIC0PORT1 ((ioport8_t *) 0x20 )42 #define PIC_PIC0PORT2 ((ioport8_t *) 0x21 )43 #define PIC_PIC1PORT1 ((ioport8_t *) 0xa0 )44 #define PIC_PIC1PORT2 ((ioport8_t *) 0xa1 )41 #define PIC_PIC0PORT1 ((ioport8_t *) 0x20U) 42 #define PIC_PIC0PORT2 ((ioport8_t *) 0x21U) 43 #define PIC_PIC1PORT1 ((ioport8_t *) 0xa0U) 44 #define PIC_PIC1PORT2 ((ioport8_t *) 0xa1U) 45 45 46 46 #define PIC_NEEDICW4 (1 << 0) … … 48 48 49 49 extern void i8259_init(void); 50 extern void pic_enable_irqs(uint16_t irqmask);51 extern void pic_disable_irqs(uint16_t irqmask);50 extern void pic_enable_irqs(uint16_t); 51 extern void pic_disable_irqs(uint16_t); 52 52 extern void pic_eoi(void); 53 53 -
kernel/arch/ia32/include/drivers/vesa.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_VESA_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 extern bool vesa_init(void); -
kernel/arch/ia32/include/faddr.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_FADDR_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 #define FADDR(fptr) 40 #define FADDR(fptr) ((uintptr_t) (fptr)) 41 41 42 42 #endif -
kernel/arch/ia32/include/fpu_context.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_FPU_CONTEXT_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 #define FPU_CONTEXT_ALIGN 16 41 42 void fpu_fxsr(void); 43 void fpu_fsr(void); 44 40 #define FPU_CONTEXT_ALIGN 16 45 41 46 42 typedef struct { 47 uint8_t fpu[512]; 43 uint8_t fpu[512]; /* FXSAVE & FXRSTOR storage area */ 48 44 } fpu_context_t; 45 46 extern void fpu_fxsr(void); 47 extern void fpu_fsr(void); 49 48 50 49 #endif -
kernel/arch/ia32/include/interrupt.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_INTERRUPT_H_ 37 37 38 #include <arch/types.h> 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 40 #include <arch/pm.h> 40 41 41 #define IVT_ITEMS 42 #define IVT_FIRST 42 #define IVT_ITEMS IDT_ITEMS 43 #define IVT_FIRST 0 43 44 44 #define EXC_COUNT 45 #define IRQ_COUNT 45 #define EXC_COUNT 32 46 #define IRQ_COUNT 16 46 47 47 #define IVT_EXCBASE 48 #define IVT_IRQBASE 49 #define IVT_FREEBASE 48 #define IVT_EXCBASE 0 49 #define IVT_IRQBASE (IVT_EXCBASE + EXC_COUNT) 50 #define IVT_FREEBASE (IVT_IRQBASE + IRQ_COUNT) 50 51 51 #define IRQ_CLK 0 52 #define IRQ_KBD 1 53 #define IRQ_PIC1 2 54 #define IRQ_PIC_SPUR 7 55 #define IRQ_MOUSE 12 52 #define IRQ_CLK 0 53 #define IRQ_KBD 1 54 #define IRQ_PIC1 2 55 #define IRQ_PIC_SPUR 7 56 #define IRQ_MOUSE 12 57 #define IRQ_NE2000 5 56 58 57 /* this one must have four least significant bits set to ones */58 #define VECTOR_APIC_SPUR 59 /* This one must have four least significant bits set to ones */ 60 #define VECTOR_APIC_SPUR (IVT_ITEMS - 1) 59 61 60 62 #if (((VECTOR_APIC_SPUR + 1) % 16) || VECTOR_APIC_SPUR >= IVT_ITEMS) … … 62 64 #endif 63 65 64 #define VECTOR_DEBUG 65 #define VECTOR_CLK 66 #define VECTOR_PIC_SPUR 67 #define VECTOR_SYSCALL 68 #define VECTOR_TLB_SHOOTDOWN_IPI 69 #define VECTOR_DEBUG_IPI 66 #define VECTOR_DEBUG 1 67 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 68 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) 69 #define VECTOR_SYSCALL IVT_FREEBASE 70 #define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE + 1) 71 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 70 72 71 typedef struct { 72 uint32_t eax;73 uint32_t ecx;74 uint32_t edx;73 extern void (* disable_irqs_function)(uint16_t); 74 extern void (* enable_irqs_function)(uint16_t); 75 extern void (* eoi_function)(void); 76 extern const char *irqs_info; 75 77 76 uint32_t gs;77 uint32_t fs;78 uint32_t es;79 uint32_t ds;80 81 uint32_t error_word;82 uint32_t eip;83 uint32_t cs;84 uint32_t eflags;85 uint32_t stack[];86 } istate_t;87 88 /** Return true if exception happened while in userspace */89 static inline int istate_from_uspace(istate_t *istate)90 {91 return !(istate->eip & 0x80000000);92 }93 94 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)95 {96 istate->eip = retaddr;97 }98 99 static inline unative_t istate_get_pc(istate_t *istate)100 {101 return istate->eip;102 }103 104 extern void (* disable_irqs_function)(uint16_t irqmask);105 extern void (* enable_irqs_function)(uint16_t irqmask);106 extern void (* eoi_function)(void);107 108 extern void decode_istate(istate_t *istate);109 78 extern void interrupt_init(void); 110 extern void trap_virtual_enable_irqs(uint16_t irqmask);111 extern void trap_virtual_disable_irqs(uint16_t irqmask);79 extern void trap_virtual_enable_irqs(uint16_t); 80 extern void trap_virtual_disable_irqs(uint16_t); 112 81 113 82 #endif -
kernel/arch/ia32/include/istate.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup sync29 /** @addtogroup ia32interrupt 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_ RWLOCK_H_36 #define KERN_ RWLOCK_H_35 #ifndef KERN_ia32_ISTATE_H_ 36 #define KERN_ia32_ISTATE_H_ 37 37 38 #include <arch/types.h> 39 #include <synch/mutex.h> 40 #include <synch/synch.h> 41 #include <synch/spinlock.h> 38 #ifdef KERNEL 42 39 43 typedef enum { 44 RWLOCK_NONE, 45 RWLOCK_READER, 46 RWLOCK_WRITER 47 } rwlock_type_t; 40 #include <typedefs.h> 41 #include <trace.h> 48 42 49 typedef struct { 50 SPINLOCK_DECLARE(lock); 51 /** 52 * Mutex for writers, readers can bypass it if readers_in is positive. 43 #else /* KERNEL */ 44 45 #include <sys/types.h> 46 47 #define NO_TRACE 48 49 #endif /* KERNEL */ 50 51 typedef struct istate { 52 /* 53 * The strange order of the GPRs is given by the requirement to use the 54 * istate structure for both regular interrupts and exceptions as well 55 * as for syscall handlers which use this order as an optimization. 53 56 */ 54 mutex_t exclusive; 55 /** Number of readers in critical section. */ 56 size_t readers_in; 57 } rwlock_t; 57 uint32_t edx; 58 uint32_t ecx; 59 uint32_t ebx; 60 uint32_t esi; 61 uint32_t edi; 62 uint32_t ebp; 63 uint32_t eax; 64 65 uint32_t ebp_frame; /* imitation of frame pointer linkage */ 66 uint32_t eip_frame; /* imitation of return address linkage */ 67 68 uint32_t gs; 69 uint32_t fs; 70 uint32_t es; 71 uint32_t ds; 72 73 uint32_t error_word; /* real or fake error word */ 74 uint32_t eip; 75 uint32_t cs; 76 uint32_t eflags; 77 uint32_t esp; /* only if istate_t is from uspace */ 78 uint32_t ss; /* only if istate_t is from uspace */ 79 } istate_t; 58 80 59 #define rwlock_write_lock(rwl) \ 60 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 61 #define rwlock_read_lock(rwl) \ 62 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 63 #define rwlock_write_trylock(rwl) \ 64 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 65 SYNCH_FLAGS_NON_BLOCKING) 66 #define rwlock_read_trylock(rwl) \ 67 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 68 SYNCH_FLAGS_NON_BLOCKING) 69 #define rwlock_write_lock_timeout(rwl, usec) \ 70 _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 71 #define rwlock_read_lock_timeout(rwl, usec) \ 72 _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 81 /** Return true if exception happened while in userspace */ 82 NO_TRACE static inline int istate_from_uspace(istate_t *istate) 83 { 84 return !(istate->eip & UINT32_C(0x80000000)); 85 } 73 86 74 extern void rwlock_initialize(rwlock_t *rwl); 75 extern void rwlock_read_unlock(rwlock_t *rwl); 76 extern void rwlock_write_unlock(rwlock_t *rwl); 77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags); 78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags); 87 NO_TRACE static inline void istate_set_retaddr(istate_t *istate, 88 uintptr_t retaddr) 89 { 90 istate->eip = retaddr; 91 } 92 93 NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate) 94 { 95 return istate->eip; 96 } 97 98 NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate) 99 { 100 return istate->ebp; 101 } 79 102 80 103 #endif -
kernel/arch/ia32/include/memstr.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 38 38 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 39 39 40 extern void memsetw(void *dst, size_t cnt, uint16_t x); 41 extern void memsetb(void *dst, size_t cnt, uint8_t x); 42 43 extern int memcmp(const void *a, const void *b, size_t cnt); 40 extern void memsetw(void *, size_t, uint16_t); 41 extern void memsetb(void *, size_t, uint8_t); 44 42 45 43 #endif -
kernel/arch/ia32/include/mm/as.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_AS_H_ 37 37 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 39 40 #define KERNEL_ADDRESS_SPACE_START_ARCH ((unsigned long)0x80000000)41 #define KERNEL_ADDRESS_SPACE_END_ARCH ((unsigned long)0xffffffff)42 #define USER_ADDRESS_SPACE_START_ARCH ((unsigned long)0x00000000)43 #define USER_ADDRESS_SPACE_END_ARCH ((unsigned long)0x7fffffff)40 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) 41 #define KERNEL_ADDRESS_SPACE_END_ARCH UINT32_C(0xffffffff) 42 #define USER_ADDRESS_SPACE_START_ARCH UINT32_C(0x00000000) 43 #define USER_ADDRESS_SPACE_END_ARCH UINT32_C(0x7fffffff) 44 44 45 #define USTACK_ADDRESS_ARCH 45 #define USTACK_ADDRESS_ARCH (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1)) 46 46 47 47 typedef struct { … … 50 50 #include <genarch/mm/as_pt.h> 51 51 52 #define as_constructor_arch(as, flags) 53 #define as_destructor_arch(as) 54 #define as_create_arch(as, flags) 52 #define as_constructor_arch(as, flags) (as != as) 53 #define as_destructor_arch(as) (as != as) 54 #define as_create_arch(as, flags) (as != as) 55 55 #define as_install_arch(as) 56 56 #define as_deinstall_arch(as) -
kernel/arch/ia32/include/mm/asid.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 43 43 #define KERN_ia32_ASID_H_ 44 44 45 #include < arch/types.h>45 #include <typedefs.h> 46 46 47 47 typedef int32_t asid_t; 48 48 49 #define ASID_MAX_ARCH 49 #define ASID_MAX_ARCH 3 50 50 51 #define asid_get() 51 #define asid_get() (ASID_START + 1) 52 52 #define asid_put(asid) 53 53 -
kernel/arch/ia32/include/mm/frame.h
rb50b5af2 r04803bf 42 42 #ifndef __ASM__ 43 43 44 #include < arch/types.h>44 #include <typedefs.h> 45 45 46 46 extern uintptr_t last_frame; -
kernel/arch/ia32/include/mm/page.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <arch/mm/frame.h> 39 40 #define PAGE_WIDTH FRAME_WIDTH 41 #define PAGE_SIZE FRAME_SIZE 39 #include <trace.h> 40 41 #define PAGE_WIDTH FRAME_WIDTH 42 #define PAGE_SIZE FRAME_SIZE 42 43 43 44 #ifdef KERNEL 44 45 45 46 #ifndef __ASM__ 46 # define KA2PA(x) (((uintptr_t) (x)) - 0x80000000) 47 # define PA2KA(x) (((uintptr_t) (x)) + 0x80000000) 48 #else 49 # define KA2PA(x) ((x) - 0x80000000) 50 # define PA2KA(x) ((x) + 0x80000000) 51 #endif 47 48 #define KA2PA(x) (((uintptr_t) (x)) - UINT32_C(0x80000000)) 49 #define PA2KA(x) (((uintptr_t) (x)) + UINT32_C(0x80000000)) 50 51 #else /* __ASM__ */ 52 53 #define KA2PA(x) ((x) - 0x80000000) 54 #define PA2KA(x) ((x) + 0x80000000) 55 56 #endif /* __ASM__ */ 52 57 53 58 /* … … 57 62 58 63 /* Number of entries in each level. */ 59 #define PTL0_ENTRIES_ARCH 60 #define PTL1_ENTRIES_ARCH 61 #define PTL2_ENTRIES_ARCH 62 #define PTL3_ENTRIES_ARCH 64 #define PTL0_ENTRIES_ARCH 1024 65 #define PTL1_ENTRIES_ARCH 0 66 #define PTL2_ENTRIES_ARCH 0 67 #define PTL3_ENTRIES_ARCH 1024 63 68 64 69 /* Page table sizes for each level. */ 65 #define PTL0_SIZE_ARCH 66 #define PTL1_SIZE_ARCH 67 #define PTL2_SIZE_ARCH 68 #define PTL3_SIZE_ARCH 70 #define PTL0_SIZE_ARCH ONE_FRAME 71 #define PTL1_SIZE_ARCH 0 72 #define PTL2_SIZE_ARCH 0 73 #define PTL3_SIZE_ARCH ONE_FRAME 69 74 70 75 /* Macros calculating indices for each level. */ 71 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff)72 #define PTL1_INDEX_ARCH(vaddr) 73 #define PTL2_INDEX_ARCH(vaddr) 74 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff)76 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ffU) 77 #define PTL1_INDEX_ARCH(vaddr) 0 78 #define PTL2_INDEX_ARCH(vaddr) 0 79 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ffU) 75 80 76 81 /* Get PTE address accessors for each level. */ … … 105 110 106 111 /* Set PTE flags accessors for each level. */ 107 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) 112 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 108 113 set_pt_flags((pte_t *) (ptl0), (size_t) (i), (x)) 109 114 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) … … 121 126 #define PTE_WRITABLE_ARCH(p) \ 122 127 ((p)->writeable != 0) 123 #define PTE_EXECUTABLE_ARCH(p) 128 #define PTE_EXECUTABLE_ARCH(p) 1 124 129 125 130 #ifndef __ASM__ … … 127 132 #include <mm/mm.h> 128 133 #include <arch/interrupt.h> 129 #include <arch/types.h>130 134 #include <typedefs.h> 131 135 … … 144 148 145 149 /** When bit on this position is 1, a reserved bit was set in page directory. */ 146 #define PFERR_CODE_RSVD (1 << 3) 147 148 static inline int get_pt_flags(pte_t *pt, size_t i) 150 #define PFERR_CODE_RSVD (1 << 3) 151 152 /** Page Table Entry. */ 153 typedef struct { 154 unsigned present : 1; 155 unsigned writeable : 1; 156 unsigned uaccessible : 1; 157 unsigned page_write_through : 1; 158 unsigned page_cache_disable : 1; 159 unsigned accessed : 1; 160 unsigned dirty : 1; 161 unsigned pat : 1; 162 unsigned global : 1; 163 unsigned soft_valid : 1; /**< Valid content even if the present bit is not set. */ 164 unsigned avl : 2; 165 unsigned frame_address : 20; 166 } __attribute__ ((packed)) pte_t; 167 168 NO_TRACE static inline unsigned int get_pt_flags(pte_t *pt, size_t i) 149 169 { 150 170 pte_t *p = &pt[i]; … … 159 179 } 160 180 161 static inline void set_pt_flags(pte_t *pt, size_t i, int flags)181 NO_TRACE static inline void set_pt_flags(pte_t *pt, size_t i, int flags) 162 182 { 163 183 pte_t *p = &pt[i]; … … 177 197 178 198 extern void page_arch_init(void); 179 extern void page_fault( int n, istate_t *istate);199 extern void page_fault(unsigned int, istate_t *); 180 200 181 201 #endif /* __ASM__ */ -
kernel/arch/ia32/include/pm.h
rb50b5af2 r04803bf 58 58 #endif /* CONFIG_FB */ 59 59 60 #define gdtselector(des) ((des) << 3)60 #define GDT_SELECTOR(des) ((des) << 3) 61 61 62 62 #define PL_KERNEL 0 … … 67 67 #define AR_CODE (3 << 3) 68 68 #define AR_WRITABLE (1 << 1) 69 #define AR_INTERRUPT (0x0e) 70 #define AR_TSS (0x09) 69 #define AR_INTERRUPT (0xe) 70 #define AR_TRAP (0xf) 71 #define AR_TSS (0x9) 71 72 72 73 #define DPL_KERNEL (PL_KERNEL << 5) … … 74 75 75 76 #define TSS_BASIC_SIZE 104 76 #define TSS_IOMAP_SIZE ( 16 * 1024 + 1) /* 16K for bitmap + 1 terminating byte for convenience */77 #define TSS_IOMAP_SIZE (8 * 1024 + 1) /* 8K for bitmap + 1 terminating byte for convenience */ 77 78 78 79 #define IO_PORTS (64 * 1024) … … 80 81 #ifndef __ASM__ 81 82 82 #include < arch/types.h>83 #include <typedefs.h> 83 84 #include <arch/context.h> 84 85 … … 152 153 153 154 extern ptr_16_32_t gdtr; 154 extern ptr_16_32_t bootstrap_gdtr;155 155 extern ptr_16_32_t protected_ap_gdtr; 156 156 extern tss_t *tss_p; -
kernel/arch/ia32/include/proc/task.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_TASK_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <adt/bitmap.h> 40 40 -
kernel/arch/ia32/include/proc/thread.h
rb50b5af2 r04803bf 36 36 #define KERN_ia32_THREAD_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 typedef struct { 41 unative_t tls;41 sysarg_t tls; 42 42 } thread_arch_t; 43 43 44 #define thr_constructor_arch(t )45 #define thr_destructor_arch(t )44 #define thr_constructor_arch(thr) 45 #define thr_destructor_arch(thr) 46 46 47 47 #endif -
kernel/arch/ia32/include/smp/ap.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ -
kernel/arch/ia32/include/smp/apic.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_APIC_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <cpu.h> 40 40 41 #define FIXED (0<<0)42 #define LOPRI (1<<0)43 44 #define APIC_ID_COUNT 41 #define FIXED (0 << 0) 42 #define LOPRI (1 << 0) 43 44 #define APIC_ID_COUNT 16 45 45 46 46 /* local APIC macros */ 47 #define IPI_INIT 48 #define IPI_STARTUP 47 #define IPI_INIT 0 48 #define IPI_STARTUP 0 49 49 50 50 /** Delivery modes. */ 51 #define DELMOD_FIXED 0x052 #define DELMOD_LOWPRI 0x153 #define DELMOD_SMI 0x251 #define DELMOD_FIXED 0x0U 52 #define DELMOD_LOWPRI 0x1U 53 #define DELMOD_SMI 0x2U 54 54 /* 0x3 reserved */ 55 #define DELMOD_NMI 0x456 #define DELMOD_INIT 0x557 #define DELMOD_STARTUP 0x658 #define DELMOD_EXTINT 0x755 #define DELMOD_NMI 0x4U 56 #define DELMOD_INIT 0x5U 57 #define DELMOD_STARTUP 0x6U 58 #define DELMOD_EXTINT 0x7U 59 59 60 60 /** Destination modes. */ 61 #define DESTMOD_PHYS 0x062 #define DESTMOD_LOGIC 0x161 #define DESTMOD_PHYS 0x0U 62 #define DESTMOD_LOGIC 0x1U 63 63 64 64 /** Trigger Modes. */ 65 #define TRIGMOD_EDGE 0x066 #define TRIGMOD_LEVEL 0x165 #define TRIGMOD_EDGE 0x0U 66 #define TRIGMOD_LEVEL 0x1U 67 67 68 68 /** Levels. */ 69 #define LEVEL_DEASSERT 0x070 #define LEVEL_ASSERT 0x169 #define LEVEL_DEASSERT 0x0U 70 #define LEVEL_ASSERT 0x1U 71 71 72 72 /** Destination Shorthands. */ 73 #define SHORTHAND_NONE 0x074 #define SHORTHAND_SELF 0x175 #define SHORTHAND_ALL_INCL 0x276 #define SHORTHAND_ALL_EXCL 0x373 #define SHORTHAND_NONE 0x0U 74 #define SHORTHAND_SELF 0x1U 75 #define SHORTHAND_ALL_INCL 0x2U 76 #define SHORTHAND_ALL_EXCL 0x3U 77 77 78 78 /** Interrupt Input Pin Polarities. */ 79 #define POLARITY_HIGH 0x080 #define POLARITY_LOW 0x179 #define POLARITY_HIGH 0x0U 80 #define POLARITY_LOW 0x1U 81 81 82 82 /** Divide Values. (Bit 2 is always 0) */ 83 #define DIVIDE_2 0x084 #define DIVIDE_4 0x185 #define DIVIDE_8 0x286 #define DIVIDE_16 0x387 #define DIVIDE_32 0x888 #define DIVIDE_64 0x989 #define DIVIDE_128 0xa90 #define DIVIDE_1 0xb83 #define DIVIDE_2 0x0U 84 #define DIVIDE_4 0x1U 85 #define DIVIDE_8 0x2U 86 #define DIVIDE_16 0x3U 87 #define DIVIDE_32 0x8U 88 #define DIVIDE_64 0x9U 89 #define DIVIDE_128 0xaU 90 #define DIVIDE_1 0xbU 91 91 92 92 /** Timer Modes. */ 93 #define TIMER_ONESHOT 0x094 #define TIMER_PERIODIC 0x193 #define TIMER_ONESHOT 0x0U 94 #define TIMER_PERIODIC 0x1U 95 95 96 96 /** Delivery status. */ 97 #define DELIVS_IDLE 0x098 #define DELIVS_PENDING 0x197 #define DELIVS_IDLE 0x0U 98 #define DELIVS_PENDING 0x1U 99 99 100 100 /** Destination masks. */ 101 #define DEST_ALL 0xff101 #define DEST_ALL 0xffU 102 102 103 103 /** Dest format models. */ 104 #define MODEL_FLAT 0xf105 #define MODEL_CLUSTER 0x0104 #define MODEL_FLAT 0xfU 105 #define MODEL_CLUSTER 0x0U 106 106 107 107 /** Interrupt Command Register. */ 108 #define ICRlo (0x300 / sizeof(uint32_t)) 109 #define ICRhi (0x310 / sizeof(uint32_t)) 108 #define ICRlo (0x300U / sizeof(uint32_t)) 109 #define ICRhi (0x310U / sizeof(uint32_t)) 110 110 111 typedef struct { 111 112 union { 112 113 uint32_t lo; 113 114 struct { 114 uint8_t vector; 115 unsigned delmod : 3;/**< Delivery Mode. */116 unsigned destmod : 1;/**< Destination Mode. */117 unsigned delivs : 1;/**< Delivery status (RO). */118 unsigned : 1;/**< Reserved. */119 unsigned level : 1;/**< Level. */120 unsigned trigger_mode : 1;/**< Trigger Mode. */121 unsigned : 2;/**< Reserved. */122 unsigned shorthand : 2;/**< Destination Shorthand. */123 unsigned : 12;/**< Reserved. */115 uint8_t vector; /**< Interrupt Vector. */ 116 unsigned int delmod : 3; /**< Delivery Mode. */ 117 unsigned int destmod : 1; /**< Destination Mode. */ 118 unsigned int delivs : 1; /**< Delivery status (RO). */ 119 unsigned int : 1; /**< Reserved. */ 120 unsigned int level : 1; /**< Level. */ 121 unsigned int trigger_mode : 1; /**< Trigger Mode. */ 122 unsigned int : 2; /**< Reserved. */ 123 unsigned int shorthand : 2; /**< Destination Shorthand. */ 124 unsigned int : 12; /**< Reserved. */ 124 125 } __attribute__ ((packed)); 125 126 }; … … 127 128 uint32_t hi; 128 129 struct { 129 unsigned : 24;/**< Reserved. */130 uint8_t dest; 130 unsigned int : 24; /**< Reserved. */ 131 uint8_t dest; /**< Destination field. */ 131 132 } __attribute__ ((packed)); 132 133 }; … … 134 135 135 136 /* End Of Interrupt. */ 136 #define EOI (0x0b0/ sizeof(uint32_t))137 #define EOI (0x0b0U / sizeof(uint32_t)) 137 138 138 139 /** Error Status Register. */ 139 #define ESR (0x280 / sizeof(uint32_t)) 140 #define ESR (0x280U / sizeof(uint32_t)) 141 140 142 typedef union { 141 143 uint32_t value; 142 144 uint8_t err_bitmap; 143 145 struct { 144 unsigned send_checksum_error : 1;145 unsigned receive_checksum_error : 1;146 unsigned send_accept_error : 1;147 unsigned receive_accept_error : 1;148 unsigned : 1;149 unsigned send_illegal_vector : 1;150 unsigned received_illegal_vector : 1;151 unsigned i llegal_register_address : 1;152 unsigned : 24;146 unsigned int send_checksum_error : 1; 147 unsigned int receive_checksum_error : 1; 148 unsigned int send_accept_error : 1; 149 unsigned int receive_accept_error : 1; 150 unsigned int : 1; 151 unsigned int send_illegal_vector : 1; 152 unsigned int received_illegal_vector : 1; 153 unsigned int illegal_register_address : 1; 154 unsigned int : 24; 153 155 } __attribute__ ((packed)); 154 156 } esr_t; 155 157 156 158 /* Task Priority Register */ 157 #define TPR (0x080 / sizeof(uint32_t)) 158 typedef union { 159 uint32_t value; 160 struct { 161 unsigned pri_sc : 4; /**< Task Priority Sub-Class. */ 162 unsigned pri : 4; /**< Task Priority. */ 159 #define TPR (0x080U / sizeof(uint32_t)) 160 161 typedef union { 162 uint32_t value; 163 struct { 164 unsigned int pri_sc : 4; /**< Task Priority Sub-Class. */ 165 unsigned int pri : 4; /**< Task Priority. */ 163 166 } __attribute__ ((packed)); 164 167 } tpr_t; 165 168 166 169 /** Spurious-Interrupt Vector Register. */ 167 #define SVR (0x0f0 / sizeof(uint32_t)) 168 typedef union { 169 uint32_t value; 170 struct { 171 uint8_t vector; /**< Spurious Vector. */ 172 unsigned lapic_enabled : 1; /**< APIC Software Enable/Disable. */ 173 unsigned focus_checking : 1; /**< Focus Processor Checking. */ 174 unsigned : 22; /**< Reserved. */ 170 #define SVR (0x0f0U / sizeof(uint32_t)) 171 172 typedef union { 173 uint32_t value; 174 struct { 175 uint8_t vector; /**< Spurious Vector. */ 176 unsigned int lapic_enabled : 1; /**< APIC Software Enable/Disable. */ 177 unsigned int focus_checking : 1; /**< Focus Processor Checking. */ 178 unsigned int : 22; /**< Reserved. */ 175 179 } __attribute__ ((packed)); 176 180 } svr_t; 177 181 178 182 /** Time Divide Configuration Register. */ 179 #define TDCR (0x3e0 / sizeof(uint32_t)) 180 typedef union { 181 uint32_t value; 182 struct { 183 unsigned div_value : 4; /**< Divide Value, bit 2 is always 0. */ 184 unsigned : 28; /**< Reserved. */ 183 #define TDCR (0x3e0U / sizeof(uint32_t)) 184 185 typedef union { 186 uint32_t value; 187 struct { 188 unsigned int div_value : 4; /**< Divide Value, bit 2 is always 0. */ 189 unsigned int : 28; /**< Reserved. */ 185 190 } __attribute__ ((packed)); 186 191 } tdcr_t; 187 192 188 193 /* Initial Count Register for Timer */ 189 #define ICRT (0x380/ sizeof(uint32_t))194 #define ICRT (0x380U / sizeof(uint32_t)) 190 195 191 196 /* Current Count Register for Timer */ 192 #define CCRT (0x390/ sizeof(uint32_t))197 #define CCRT (0x390U / sizeof(uint32_t)) 193 198 194 199 /** LVT Timer register. */ 195 #define LVT_Tm (0x320 / sizeof(uint32_t)) 196 typedef union { 197 uint32_t value; 198 struct { 199 uint8_t vector; /**< Local Timer Interrupt vector. */ 200 unsigned : 4; /**< Reserved. */ 201 unsigned delivs : 1; /**< Delivery status (RO). */ 202 unsigned : 3; /**< Reserved. */ 203 unsigned masked : 1; /**< Interrupt Mask. */ 204 unsigned mode : 1; /**< Timer Mode. */ 205 unsigned : 14; /**< Reserved. */ 200 #define LVT_Tm (0x320U / sizeof(uint32_t)) 201 202 typedef union { 203 uint32_t value; 204 struct { 205 uint8_t vector; /**< Local Timer Interrupt vector. */ 206 unsigned int : 4; /**< Reserved. */ 207 unsigned int delivs : 1; /**< Delivery status (RO). */ 208 unsigned int : 3; /**< Reserved. */ 209 unsigned int masked : 1; /**< Interrupt Mask. */ 210 unsigned int mode : 1; /**< Timer Mode. */ 211 unsigned int : 14; /**< Reserved. */ 206 212 } __attribute__ ((packed)); 207 213 } lvt_tm_t; 208 214 209 215 /** LVT LINT registers. */ 210 #define LVT_LINT0 (0x350 / sizeof(uint32_t)) 211 #define LVT_LINT1 (0x360 / sizeof(uint32_t)) 212 typedef union { 213 uint32_t value; 214 struct { 215 uint8_t vector; /**< LINT Interrupt vector. */ 216 unsigned delmod : 3; /**< Delivery Mode. */ 217 unsigned : 1; /**< Reserved. */ 218 unsigned delivs : 1; /**< Delivery status (RO). */ 219 unsigned intpol : 1; /**< Interrupt Input Pin Polarity. */ 220 unsigned irr : 1; /**< Remote IRR (RO). */ 221 unsigned trigger_mode : 1; /**< Trigger Mode. */ 222 unsigned masked : 1; /**< Interrupt Mask. */ 223 unsigned : 15; /**< Reserved. */ 216 #define LVT_LINT0 (0x350U / sizeof(uint32_t)) 217 #define LVT_LINT1 (0x360U / sizeof(uint32_t)) 218 219 typedef union { 220 uint32_t value; 221 struct { 222 uint8_t vector; /**< LINT Interrupt vector. */ 223 unsigned int delmod : 3; /**< Delivery Mode. */ 224 unsigned int : 1; /**< Reserved. */ 225 unsigned int delivs : 1; /**< Delivery status (RO). */ 226 unsigned int intpol : 1; /**< Interrupt Input Pin Polarity. */ 227 unsigned int irr : 1; /**< Remote IRR (RO). */ 228 unsigned int trigger_mode : 1; /**< Trigger Mode. */ 229 unsigned int masked : 1; /**< Interrupt Mask. */ 230 unsigned int : 15; /**< Reserved. */ 224 231 } __attribute__ ((packed)); 225 232 } lvt_lint_t; 226 233 227 234 /** LVT Error register. */ 228 #define LVT_Err (0x370 / sizeof(uint32_t)) 229 typedef union { 230 uint32_t value; 231 struct { 232 uint8_t vector; /**< Local Timer Interrupt vector. */ 233 unsigned : 4; /**< Reserved. */ 234 unsigned delivs : 1; /**< Delivery status (RO). */ 235 unsigned : 3; /**< Reserved. */ 236 unsigned masked : 1; /**< Interrupt Mask. */ 237 unsigned : 15; /**< Reserved. */ 235 #define LVT_Err (0x370U / sizeof(uint32_t)) 236 237 typedef union { 238 uint32_t value; 239 struct { 240 uint8_t vector; /**< Local Timer Interrupt vector. */ 241 unsigned int : 4; /**< Reserved. */ 242 unsigned int delivs : 1; /**< Delivery status (RO). */ 243 unsigned int : 3; /**< Reserved. */ 244 unsigned int masked : 1; /**< Interrupt Mask. */ 245 unsigned int : 15; /**< Reserved. */ 238 246 } __attribute__ ((packed)); 239 247 } lvt_error_t; 240 248 241 249 /** Local APIC ID Register. */ 242 #define L_APIC_ID (0x020 / sizeof(uint32_t)) 243 typedef union { 244 uint32_t value; 245 struct { 246 unsigned : 24; /**< Reserved. */ 247 uint8_t apic_id; /**< Local APIC ID. */ 250 #define L_APIC_ID (0x020U / sizeof(uint32_t)) 251 252 typedef union { 253 uint32_t value; 254 struct { 255 unsigned int : 24; /**< Reserved. */ 256 uint8_t apic_id; /**< Local APIC ID. */ 248 257 } __attribute__ ((packed)); 249 258 } l_apic_id_t; 250 259 251 260 /** Local APIC Version Register */ 252 #define LAVR (0x030 / sizeof(uint32_t)) 253 #define LAVR_Mask 0xff 254 #define is_local_apic(x) (((x) & LAVR_Mask & 0xf0) == 0x1) 255 #define is_82489DX_apic(x) ((((x) & LAVR_Mask & 0xf0) == 0x0)) 256 #define is_local_xapic(x) (((x) & LAVR_Mask) == 0x14) 261 #define LAVR (0x030U / sizeof(uint32_t)) 262 #define LAVR_Mask 0xffU 263 264 #define is_local_apic(x) (((x) & LAVR_Mask & 0xf0U) == 0x1U) 265 #define is_82489DX_apic(x) ((((x) & LAVR_Mask & 0xf0U) == 0x0U)) 266 #define is_local_xapic(x) (((x) & LAVR_Mask) == 0x14U) 257 267 258 268 /** Logical Destination Register. */ 259 #define LDR (0x0d0 / sizeof(uint32_t)) 260 typedef union { 261 uint32_t value; 262 struct { 263 unsigned : 24; /**< Reserved. */ 264 uint8_t id; /**< Logical APIC ID. */ 269 #define LDR (0x0d0U / sizeof(uint32_t)) 270 271 typedef union { 272 uint32_t value; 273 struct { 274 unsigned int : 24; /**< Reserved. */ 275 uint8_t id; /**< Logical APIC ID. */ 265 276 } __attribute__ ((packed)); 266 277 } ldr_t; 267 278 268 279 /** Destination Format Register. */ 269 #define DFR (0x0e0 / sizeof(uint32_t)) 270 typedef union { 271 uint32_t value; 272 struct { 273 unsigned : 28; /**< Reserved, all ones. */ 274 unsigned model : 4; /**< Model. */ 280 #define DFR (0x0e0U / sizeof(uint32_t)) 281 282 typedef union { 283 uint32_t value; 284 struct { 285 unsigned int : 28; /**< Reserved, all ones. */ 286 unsigned int model : 4; /**< Model. */ 275 287 } __attribute__ ((packed)); 276 288 } dfr_t; 277 289 278 290 /* IO APIC */ 279 #define IOREGSEL (0x00/ sizeof(uint32_t))280 #define IOWIN (0x10/ sizeof(uint32_t))281 282 #define IOAPICID 0x00283 #define IOAPICVER 0x01284 #define IOAPICARB 0x02285 #define IOREDTBL 0x10291 #define IOREGSEL (0x00U / sizeof(uint32_t)) 292 #define IOWIN (0x10U / sizeof(uint32_t)) 293 294 #define IOAPICID 0x00U 295 #define IOAPICVER 0x01U 296 #define IOAPICARB 0x02U 297 #define IOREDTBL 0x10U 286 298 287 299 /** I/O Register Select Register. */ … … 289 301 uint32_t value; 290 302 struct { 291 uint8_t reg_addr; 292 unsigned : 24;/**< Reserved. */303 uint8_t reg_addr; /**< APIC Register Address. */ 304 unsigned int : 24; /**< Reserved. */ 293 305 } __attribute__ ((packed)); 294 306 } io_regsel_t; … … 299 311 uint32_t lo; 300 312 struct { 301 uint8_t intvec; 302 unsigned delmod : 3;/**< Delivery Mode. */303 unsigned destmod : 1;/**< Destination mode. */304 unsigned delivs : 1;/**< Delivery status (RO). */305 unsigned int pol : 1;/**< Interrupt Input Pin Polarity. */306 unsigned i rr : 1;/**< Remote IRR (RO). */307 unsigned trigger_mode : 1;/**< Trigger Mode. */308 unsigned masked : 1;/**< Interrupt Mask. */309 unsigned : 15;/**< Reserved. */313 uint8_t intvec; /**< Interrupt Vector. */ 314 unsigned int delmod : 3; /**< Delivery Mode. */ 315 unsigned int destmod : 1; /**< Destination mode. */ 316 unsigned int delivs : 1; /**< Delivery status (RO). */ 317 unsigned int intpol : 1; /**< Interrupt Input Pin Polarity. */ 318 unsigned int irr : 1; /**< Remote IRR (RO). */ 319 unsigned int trigger_mode : 1; /**< Trigger Mode. */ 320 unsigned int masked : 1; /**< Interrupt Mask. */ 321 unsigned int : 15; /**< Reserved. */ 310 322 } __attribute__ ((packed)); 311 323 }; … … 313 325 uint32_t hi; 314 326 struct { 315 unsigned : 24;/**< Reserved. */316 uint8_t dest : 8; 327 unsigned int : 24; /**< Reserved. */ 328 uint8_t dest : 8; /**< Destination Field. */ 317 329 } __attribute__ ((packed)); 318 330 }; … … 325 337 uint32_t value; 326 338 struct { 327 unsigned : 24;/**< Reserved. */328 unsigned apic_id : 4;/**< IO APIC ID. */329 unsigned : 4;/**< Reserved. */339 unsigned int : 24; /**< Reserved. */ 340 unsigned int apic_id : 4; /**< IO APIC ID. */ 341 unsigned int : 4; /**< Reserved. */ 330 342 } __attribute__ ((packed)); 331 343 } io_apic_id_t; … … 335 347 336 348 extern uint32_t apic_id_mask; 349 extern uint8_t bsp_l_apic; 337 350 338 351 extern void apic_init(void); … … 340 353 extern void l_apic_init(void); 341 354 extern void l_apic_eoi(void); 342 extern int l_apic_broadcast_custom_ipi(uint8_t vector);343 extern int l_apic_send_init_ipi(uint8_t apicid);355 extern int l_apic_broadcast_custom_ipi(uint8_t); 356 extern int l_apic_send_init_ipi(uint8_t); 344 357 extern void l_apic_debug(void); 345 extern uint8_t l_apic_id(void); 346 347 extern uint32_t io_apic_read(uint8_t address); 348 extern void io_apic_write(uint8_t address , uint32_t x); 349 extern void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t v, int flags); 350 extern void io_apic_disable_irqs(uint16_t irqmask); 351 extern void io_apic_enable_irqs(uint16_t irqmask); 358 359 extern uint32_t io_apic_read(uint8_t); 360 extern void io_apic_write(uint8_t, uint32_t); 361 extern void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t v, unsigned int); 362 extern void io_apic_disable_irqs(uint16_t); 363 extern void io_apic_enable_irqs(uint16_t); 352 364 353 365 #endif -
kernel/arch/ia32/include/smp/mps.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_MPS_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <synch/waitq.h> 40 40 #include <config.h> 41 41 #include <arch/smp/smp.h> 42 42 43 #define CT_EXT_ENTRY_TYPE 44 #define CT_EXT_ENTRY_LEN 43 #define CT_EXT_ENTRY_TYPE 0 44 #define CT_EXT_ENTRY_LEN 1 45 45 46 46 struct mps_fs { … … 70 70 uint16_t ext_table_length; 71 71 uint8_t ext_table_checksum; 72 uint8_t xxx;72 uint8_t reserved; 73 73 uint8_t base_table[0]; 74 74 } __attribute__ ((packed)); … … 81 81 uint8_t cpu_signature[4]; 82 82 uint32_t feature_flags; 83 uint32_t xxx[2];83 uint32_t reserved[2]; 84 84 } __attribute__ ((packed)); 85 85 … … 102 102 uint8_t intr_type; 103 103 uint8_t poel; 104 uint8_t xxx;104 uint8_t reserved; 105 105 uint8_t src_bus_id; 106 106 uint8_t src_bus_irq; … … 113 113 uint8_t intr_type; 114 114 uint8_t poel; 115 uint8_t xxx;115 uint8_t reserved; 116 116 uint8_t src_bus_id; 117 117 uint8_t src_bus_irq; -
kernel/arch/ia32/include/smp/smp.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_SMP_H_ 37 37 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 /** SMP config opertaions interface. */ 41 41 struct smp_config_operations { 42 size_t (* cpu_count)(void); /**< Return number of detected processors. */ 43 bool (* cpu_enabled)(size_t i); /**< Check whether the processor of index i is enabled. */ 44 bool (*cpu_bootstrap)(size_t i); /**< Check whether the processor of index i is BSP. */ 45 uint8_t (*cpu_apic_id)(size_t i); /**< Return APIC ID of the processor of index i. */ 46 int (*irq_to_pin)(unsigned int irq); /**< Return mapping between irq and APIC pin. */ 42 /** Check whether a processor is enabled. */ 43 bool (* cpu_enabled)(size_t); 44 45 /** Check whether a processor is BSP. */ 46 bool (*cpu_bootstrap)(size_t); 47 48 /** Return APIC ID of a processor. */ 49 uint8_t (*cpu_apic_id)(size_t); 50 51 /** Return mapping between IRQ and APIC pin. */ 52 int (*irq_to_pin)(unsigned int); 47 53 }; 48 54 49 extern int smp_irq_to_pin(unsigned int irq);55 extern int smp_irq_to_pin(unsigned int); 50 56 51 57 #endif -
kernel/arch/ia32/include/types.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia32_TYPES_H_ 37 37 38 typedef signed char int8_t;39 typedef signed short int16_t;40 typedef signed long int32_t;41 typedef signed long long int64_t;42 43 typedef unsigned char uint8_t;44 typedef unsigned short uint16_t;45 typedef unsigned long uint32_t;46 typedef unsigned long long uint64_t;47 48 38 typedef uint32_t size_t; 49 39 … … 53 43 typedef uint32_t ipl_t; 54 44 55 typedef uint32_t unative_t;45 typedef uint32_t sysarg_t; 56 46 typedef int32_t native_t; 47 typedef uint32_t atomic_count_t; 57 48 58 49 typedef struct { 59 50 } fncptr_t; 60 51 61 #define PRIp "x" /**< Format for uintptr_t. */62 #define PRIs "u" /**< Format for size_t. */52 #define INTN_C(c) INT32_C(c) 53 #define UINTN_C(c) UINT32_C(c) 63 54 64 #define PRId8 "d" /**< Format for int8_t. */ 65 #define PRId16 "d" /**< Format for int16_t. */ 66 #define PRId32 "d" /**< Format for int32_t. */ 67 #define PRId64 "lld" /**< Format for int64_t. */ 68 #define PRIdn "d" /**< Format for native_t. */ 69 70 #define PRIu8 "u" /**< Format for uint8_t. */ 71 #define PRIu16 "u" /**< Format for uint16_t. */ 72 #define PRIu32 "u" /**< Format for uint32_t. */ 73 #define PRIu64 "llu" /**< Format for uint64_t. */ 74 #define PRIun "u" /**< Format for unative_t. */ 75 76 #define PRIx8 "x" /**< Format for hexadecimal (u)int8_t. */ 77 #define PRIx16 "x" /**< Format for hexadecimal (u)int16_t. */ 78 #define PRIx32 "x" /**< Format for hexadecimal (u)uint32_t. */ 79 #define PRIx64 "llx" /**< Format for hexadecimal (u)int64_t. */ 80 #define PRIxn "x" /**< Format for hexadecimal (u)native_t. */ 81 82 /** Page Table Entry. */ 83 typedef struct { 84 unsigned present : 1; 85 unsigned writeable : 1; 86 unsigned uaccessible : 1; 87 unsigned page_write_through : 1; 88 unsigned page_cache_disable : 1; 89 unsigned accessed : 1; 90 unsigned dirty : 1; 91 unsigned pat : 1; 92 unsigned global : 1; 93 unsigned soft_valid : 1; /**< Valid content even if the present bit is not set. */ 94 unsigned avl : 2; 95 unsigned frame_address : 20; 96 } __attribute__ ((packed)) pte_t; 55 #define PRIdn PRId32 /**< Format for native_t. */ 56 #define PRIun PRIu32 /**< Format for sysarg_t. */ 57 #define PRIxn PRIx32 /**< Format for hexadecimal sysarg_t. */ 58 #define PRIua PRIu32 /**< Format for atomic_count_t. */ 97 59 98 60 #endif
Note:
See TracChangeset
for help on using the changeset viewer.