Changeset 18e0a6c in mainline
- Timestamp:
- 2005-06-09T23:43:45Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 74df77d
- Parents:
- d896525
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/include/asm.h
rd896525 r18e0a6c 38 38 39 39 extern void paging_on(void); 40 extern __address cpu_read_dba(void);41 extern void cpu_write_dba(__address dba);42 43 extern __address cpu_read_cr2(void);44 40 45 41 extern void interrupt_handlers(void); … … 55 51 extern void enable_l_apic_in_msr(void); 56 52 57 extern void halt_cpu(void); 58 extern void cpu_sleep(void); 53 /** Halt CPU 54 * 55 * Halt the current CPU until interrupt event. 56 */ 57 static inline void cpu_halt(void) { __asm__("hlt"); }; 58 static inline void cpu_sleep(void) { __asm__("hlt"); }; 59 59 60 static inline void write_dr0(__u32 v); 61 static inline __u32 read_dr0(void); 60 /** Read CR2 61 * 62 * Return value in CR2 63 * 64 * @return Value read. 65 */ 66 static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0" : "=r" (v)); return v; } 62 67 63 inline void write_dr0(__u32 v) { __asm__ volatile ("movl %0,%%dr0\n" : : "r" (v)); } 64 inline __u32 read_dr0(void) { __u32 v; __asm__ volatile ("movl %%dr0,%0" : "=r" (v)); return v; } 68 /** Write CR3 69 * 70 * Write value to CR3. 71 * 72 * @param v Value to be written. 73 */ 74 static inline void write_cr3(__u32 v) { __asm__ volatile ("movl %0,%%cr3\n" : : "r" (v)); } 75 76 /** Read CR3 77 * 78 * Return value in CR3 79 * 80 * @return Value read. 81 */ 82 static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0" : "=r" (v)); return v; } 83 84 /** Write DR0 85 * 86 * Write value to DR0. 87 * 88 * @param v Value to be written. 89 */ 90 static inline void write_dr0(__u32 v) { __asm__ volatile ("movl %0,%%dr0\n" : : "r" (v)); } 91 92 /** Read DR0 93 * 94 * Return value in DR0 95 * 96 * @return Value read. 97 */ 98 static inline __u32 read_dr0(void) { __u32 v; __asm__ volatile ("movl %%dr0,%0" : "=r" (v)); return v; } 99 100 /** Set priority level low 101 * 102 * Enable interrupts and return previous 103 * value of EFLAGS. 104 */ 105 static inline pri_t cpu_priority_low(void) { 106 pri_t v; 107 __asm__ volatile ( 108 "pushf\n" 109 "popl %0\n" 110 "sti\n" 111 : "=r" (v) 112 ); 113 return v; 114 } 115 116 /** Set priority level high 117 * 118 * Disable interrupts and return previous 119 * value of EFLAGS. 120 */ 121 static inline pri_t cpu_priority_high(void) { 122 pri_t v; 123 __asm__ volatile ( 124 "pushf\n" 125 "popl %0\n" 126 "cli\n" 127 : "=r" (v) 128 ); 129 return v; 130 } 131 132 /** Restore priority level 133 * 134 * Restore EFLAGS. 135 */ 136 static inline void cpu_priority_restore(pri_t pri) { 137 __asm__ volatile ( 138 "pushl %0\n" 139 "popf\n" 140 : : "r" (pri) 141 ); 142 } 143 144 /** Return raw priority level 145 * 146 * Return EFLAFS. 147 */ 148 static inline pri_t cpu_priority_read(void) { 149 pri_t v; 150 __asm__ volatile ( 151 "pushf\n" 152 "popl %0\n" 153 : "=r" (v) 154 ); 155 return v; 156 } 65 157 66 158 #endif -
arch/ia32/include/atomic.h
rd896525 r18e0a6c 32 32 #include <arch/types.h> 33 33 34 extern void atomic_inc(volatile int *val); 35 extern void atomic_dec(volatile int *val); 34 static inline void atomic_inc(volatile int *val) { 35 #ifdef __SMP__ 36 __asm__ volatile ("lock incl (%0)\n" : : "r" (val)); 37 #else 38 __asm__ volatile ("incl (%0)\n" : : "r" (val)); 39 #endif /* __SMP__ */ 40 } 36 41 37 extern int test_and_set(int *val); 42 static inline void atomic_dec(volatile int *val) { 43 #ifdef __SMP__ 44 __asm__ volatile ("lock decl (%0)\n" : : "r" (val)); 45 #else 46 __asm__ volatile ("decl (%0)\n" : : "r" (val)); 47 #endif /* __SMP__ */ 48 } 49 50 static inline int test_and_set(int *val) { 51 int v; 52 53 __asm__ volatile ( 54 "movl $1, %0\n" 55 "xchgl %0, (%1)\n" 56 : "=r" (v) 57 : "r" (val) 58 ); 59 60 return v; 61 } 62 63 38 64 extern void spinlock_arch(int *val); 39 65 -
arch/ia32/src/asm.s
rd896525 r18e0a6c 31 31 .text 32 32 33 .global cpu_priority_high34 .global cpu_priority_low35 .global cpu_priority_restore36 .global cpu_priority_read37 33 .global cpu_halt 38 34 .global cpu_sleep 39 35 .global paging_on 40 .global cpu_read_dba41 .global cpu_write_dba42 .global cpu_read_cr243 36 .global enable_l_apic_in_msr 44 37 .global interrupt_handlers … … 55 48 56 49 57 ## Set priority level high58 #59 # Disable interrupts and return previous60 # EFLAGS in EAX.61 #62 cpu_priority_high:63 pushf64 pop %eax65 cli66 ret67 68 69 ## Set priority level low70 #71 # Enable interrupts and return previous72 # EFLAGS in EAX.73 #74 cpu_priority_low:75 pushf76 pop %eax77 sti78 ret79 80 81 ## Restore priority level82 #83 # Restore EFLAGS.84 #85 cpu_priority_restore:86 push 4(%esp)87 popf88 ret89 90 ## Return raw priority level91 #92 # Return EFLAFS in EAX.93 #94 cpu_priority_read:95 pushf96 pop %eax97 ret98 99 100 ## Halt the CPU101 #102 # Halt the CPU using HLT.103 #104 cpu_halt:105 cpu_sleep:106 hlt107 ret108 109 110 50 ## Turn paging on 111 51 # … … 124 64 125 65 126 ## Read CR3127 #128 # Store CR3 in EAX.129 #130 cpu_read_dba:131 movl %cr3,%eax132 ret133 134 135 ## Write CR3136 #137 # Set CR3.138 #139 cpu_write_dba:140 pushl %eax141 movl 8(%esp),%eax142 movl %eax,%cr3143 popl %eax144 ret145 146 147 ## Read CR2148 #149 # Store CR2 in EAX.150 #151 cpu_read_cr2:152 movl %cr2,%eax153 ret154 155 156 66 ## Enable local APIC 157 67 # -
arch/ia32/src/atomic.S
rd896525 r18e0a6c 29 29 .text 30 30 31 .global atomic_inc32 atomic_inc:33 pushl %ebx34 movl 8(%esp),%ebx35 #ifdef __SMP__36 lock incl (%ebx)37 #else38 incl (%ebx)39 #endif40 popl %ebx41 ret42 43 .global atomic_dec44 atomic_dec:45 pushl %ebx46 movl 8(%esp),%ebx47 #ifdef __SMP__48 lock decl (%ebx)49 #else50 decl (%ebx)51 #endif52 popl %ebx53 ret54 55 56 31 #ifdef __SMP__ 57 32 58 59 .global test_and_set60 33 .global spinlock_arch 61 62 test_and_set:63 pushl %ebx64 65 movl 8(%esp),%ebx66 movl $1,%eax67 xchgl %eax,(%ebx) # xchg implicitly turns on the LOCK signal68 69 popl %ebx70 ret71 72 34 73 35 # -
arch/ia32/src/interrupt.c
rd896525 r18e0a6c 112 112 void page_fault(__u8 n, __u32 stack[]) 113 113 { 114 printf("page fault address: %X\n", cpu_read_cr2());114 printf("page fault address: %X\n", read_cr2()); 115 115 printf("stack[0]=%X, %%eip=%X, %%cs=%X, flags=%X\n", stack[0], stack[1], stack[2], stack[3]); 116 116 printf("%%eax=%L, %%ebx=%L, %%ecx=%L, %%edx=%L,\n%%edi=%L, %%esi=%L, %%ebp=%L, %%esp=%L\n", stack[-2], stack[-5], stack[-3], stack[-4], stack[-9], stack[-8], stack[-1], stack); -
arch/ia32/src/mm/page.c
rd896525 r18e0a6c 70 70 71 71 trap_register(14, page_fault); 72 cpu_write_dba(KA2PA(dba));72 write_cr3(KA2PA(dba)); 73 73 } 74 74 else { … … 82 82 dba = frame_alloc(FRAME_KA | FRAME_PANIC); 83 83 memcopy(bootstrap_dba, dba, PAGE_SIZE); 84 cpu_write_dba(KA2PA(dba));84 write_cr3(KA2PA(dba)); 85 85 } 86 86 … … 108 108 109 109 if (root) dba = root; 110 else dba = cpu_read_dba();110 else dba = read_cr3(); 111 111 112 112 pde = page >> 22; /* page directory entry */ -
arch/ia32/src/mm/tlb.c
rd896525 r18e0a6c 32 32 void tlb_invalidate(int asid) 33 33 { 34 cpu_write_dba(cpu_read_dba());34 write_cr3(read_cr3()); 35 35 } -
arch/ia32/src/smp/apic.c
rd896525 r18e0a6c 45 45 * Tested on: 46 46 * Bochs 2.0.2 - Bochs 2.2 with 2-8 CPUs 47 * Simics 2.0.28 47 48 * ASUS P/I-P65UP5 + ASUS C-P55T2D REV. 1.41 with 2x 200Mhz Pentium CPUs 48 49 */ -
doc/requirements
rd896525 r18e0a6c 2 2 ========= 3 3 4 5 4 HARDWARE REQUIREMENTS 5 o IA-32 processor (Pentium and successors) 6 6 7 8 9 10 7 COMPILER REQUIREMENTS 8 o binutils 2.15 9 o gcc 2.95 10 o gcc 3.3.2 - gcc 3.3.5 11 11 12 SMP COMPATIBILITY 13 o Bochs 2.0.2 - Bochs 2.2 14 o 2x-8x 686 CPU 15 o ASUS P/I-P65UP5 + ASUS C-P55T2D REV. 1.41 16 o 2x 200Mhz Pentium CPU 12 SMP COMPATIBILITY 13 o Bochs 2.0.2 - Bochs 2.2 14 o 2x-8x 686 CPU 15 o Simics 2.0.28 16 o 4x Pentium 4 CPU 17 o ASUS P/I-P65UP5 + ASUS C-P55T2D REV. 1.41 18 o 2x 200Mhz Pentium CPU 17 19 18 19 o Bochs 2.0.2 - Bochs 2.2-cvs 20 20 EMULATORS AND VIRTUALIZERS 21 o Bochs 2.0.2 - Bochs 2.2 22 o VMware Workstation 4, VMware Workstation 5 21 23 22 24 … … 24 26 ========= 25 27 26 27 28 28 HARDWARE REQUIREMENTS 29 o no real hardware supported 30 o msim emulated MIPS R4000 CPU (see mips) 29 31 30 31 32 33 32 COMPILER REQUIREMENTS 33 o binutils 2.14 mips cross binutils 34 o gcc 2.8.1 mips cross compiler 35 o gcc 3.2.3 mips cross compiler 34 36 35 36 37 EMULATORS AND VIRTUALIZERS 38 o msim 37 39 38 40 ia64 port 39 41 ========= 40 42 41 42 43 HARDWARE REQUIREMENTS 44 o no real hardware supported 43 45 44 45 46 EMULATORS AND VIRTUALIZERS 47 o ski -
src/debug/print.c
rd896525 r18e0a6c 31 31 #include <synch/spinlock.h> 32 32 #include <arch/arg.h> 33 #include <arch/asm.h> 33 34 34 35 -
src/mm/frame.c
rd896525 r18e0a6c 42 42 43 43 #include <synch/spinlock.h> 44 45 #include <arch/asm.h> 44 46 45 47 count_t frames = 0; -
src/mm/heap.c
rd896525 r18e0a6c 33 33 #include <panic.h> 34 34 #include <arch/types.h> 35 #include <arch/asm.h> 35 36 36 37 /* -
src/mm/vm.c
rd896525 r18e0a6c 39 39 #include <list.h> 40 40 #include <panic.h> 41 #include <arch/asm.h> 41 42 42 43 vm_t *vm_create(void) -
src/proc/scheduler.c
rd896525 r18e0a6c 132 132 } 133 133 134 /* avoid deadlock with relink_rq */134 /* avoid deadlock with relink_rq() */ 135 135 if (!spinlock_trylock(&CPU->lock)) { 136 136 /* … … 447 447 448 448 cpu = &cpus[(i + k) % config.cpu_active]; 449 r = &cpu->rq[j];450 449 451 450 /* … … 454 453 */ 455 454 if (CPU == cpu) 456 continue; 455 continue; 457 456 458 457 restart: pri = cpu_priority_high(); 458 r = &cpu->rq[j]; 459 459 spinlock_lock(&r->lock); 460 460 if (r->n == 0) { … … 471 471 * We don't want to steal CPU-wired threads neither threads already stolen. 472 472 * The latter prevents threads from migrating between CPU's without ever being run. 473 * We don't want to steal threads whose FPU context is still in CPU 473 * We don't want to steal threads whose FPU context is still in CPU. 474 474 */ 475 475 spinlock_lock(&t->lock); 476 476 if ( (!(t->flags & (X_WIRED | X_STOLEN))) && (!(t->fpu_context_engaged)) ) { 477 477 478 /* 478 479 * Remove t from r. -
src/proc/thread.c
rd896525 r18e0a6c 177 177 frame_ks = frame_alloc(FRAME_KA); 178 178 if (THREAD_USER_STACK & flags) { 179 frame_us = frame_alloc( 0);179 frame_us = frame_alloc(FRAME_KA); 180 180 } 181 181 -
src/synch/semaphore.c
rd896525 r18e0a6c 31 31 #include <synch/waitq.h> 32 32 #include <synch/spinlock.h> 33 #include <arch/asm.h> 33 34 34 35 void semaphore_initialize(semaphore_t *s, int val)
Note:
See TracChangeset
for help on using the changeset viewer.