Changeset 3500f75 in mainline
- Timestamp:
- 2010-05-21T22:50:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c8e1e1
- Parents:
- 339249f
- Location:
- kernel/arch/ppc32
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ppc32/include/asm.h
r339249f r3500f75 38 38 #include <typedefs.h> 39 39 #include <config.h> 40 #include <arch/cpu.h> 41 42 static inline uint32_t msr_read(void) 43 { 44 uint32_t msr; 45 46 asm volatile ( 47 "mfmsr %[msr]\n" 48 : [msr] "=r" (msr) 49 ); 50 51 return msr; 52 } 53 54 static inline void msr_write(uint32_t msr) 55 { 56 asm volatile ( 57 "mtmsr %[msr]\n" 58 :: [msr] "r" (msr) 59 ); 60 } 40 61 41 62 /** Enable interrupts. … … 45 66 * 46 67 * @return Old interrupt priority level. 68 * 47 69 */ 48 70 static inline ipl_t interrupts_enable(void) 49 71 { 50 ipl_t v; 51 ipl_t tmp; 52 53 asm volatile ( 54 "mfmsr %0\n" 55 "mfmsr %1\n" 56 "ori %1, %1, 1 << 15\n" 57 "mtmsr %1\n" 58 : "=r" (v), "=r" (tmp) 59 ); 60 return v; 72 ipl_t ipl = msr_read(); 73 msr_write(ipl | MSR_EE); 74 return ipl; 61 75 } 62 76 … … 67 81 * 68 82 * @return Old interrupt priority level. 83 * 69 84 */ 70 85 static inline ipl_t interrupts_disable(void) 71 86 { 72 ipl_t v; 73 ipl_t tmp; 74 75 asm volatile ( 76 "mfmsr %0\n" 77 "mfmsr %1\n" 78 "rlwinm %1, %1, 0, 17, 15\n" 79 "mtmsr %1\n" 80 : "=r" (v), "=r" (tmp) 81 ); 82 return v; 87 ipl_t ipl = msr_read(); 88 msr_write(ipl & (~MSR_EE)); 89 return ipl; 83 90 } 84 91 … … 88 95 * 89 96 * @param ipl Saved interrupt priority level. 97 * 90 98 */ 91 99 static inline void interrupts_restore(ipl_t ipl) 92 100 { 93 ipl_t tmp; 94 95 asm volatile ( 96 "mfmsr %1\n" 97 "rlwimi %0, %1, 0, 17, 15\n" 98 "cmpw 0, %0, %1\n" 99 "beq 0f\n" 100 "mtmsr %0\n" 101 "0:\n" 102 : "=r" (ipl), "=r" (tmp) 103 : "0" (ipl) 104 : "cr0" 105 ); 101 msr_write((msr_read() & (~MSR_EE)) | (ipl & MSR_EE)); 106 102 } 107 103 … … 111 107 * 112 108 * @return Current interrupt priority level. 109 * 113 110 */ 114 111 static inline ipl_t interrupts_read(void) 115 112 { 116 ipl_t v; 117 118 asm volatile ( 119 "mfmsr %0\n" 120 : "=r" (v) 121 ); 122 return v; 113 return msr_read(); 114 } 115 116 /** Check whether interrupts are disabled. 117 * 118 * @return True if interrupts are disabled. 119 * 120 */ 121 static inline bool interrupts_disabled(void) 122 { 123 return ((msr_read() & MSR_EE) == 0); 123 124 } 124 125 … … 128 129 * The stack is assumed to be STACK_SIZE bytes long. 129 130 * The stack must start on page boundary. 131 * 130 132 */ 131 133 static inline uintptr_t get_stack_base(void) 132 134 { 133 uintptr_t v;135 uintptr_t base; 134 136 135 137 asm volatile ( 136 "and % 0, %%sp, %1\n"137 : "=r" (v)138 : "r" (~(STACK_SIZE - 1))138 "and %[base], %%sp, %[mask]\n" 139 : [base] "=r" (base) 140 : [mask] "r" (~(STACK_SIZE - 1)) 139 141 ); 140 return v; 142 143 return base; 141 144 } 142 145 -
kernel/arch/ppc32/include/cpu.h
r339249f r3500f75 36 36 #define KERN_ppc32_CPU_H_ 37 37 38 #include <arch/asm.h> 38 /* MSR bits */ 39 #define MSR_DR (1 << 4) 40 #define MSR_IR (1 << 5) 41 #define MSR_PR (1 << 14) 42 #define MSR_EE (1 << 15) 43 44 /* HID0 bits */ 45 #define HID0_STEN (1 << 24) 46 #define HID0_ICE (1 << 15) 47 #define HID0_DCE (1 << 14) 48 #define HID0_ICFI (1 << 11) 49 #define HID0_DCI (1 << 10) 50 51 #ifndef __ASM__ 52 53 #include <typedefs.h> 39 54 40 55 typedef struct { 41 int version; 42 int revision; 43 } cpu_arch_t; 44 56 uint16_t version; 57 uint16_t revision; 58 } __attribute__ ((packed)) cpu_arch_t; 59 60 static inline void cpu_version(cpu_arch_t *info) 61 { 62 asm volatile ( 63 "mfpvr %[cpu_info]\n" 64 : [cpu_info] "=r" (*info) 65 ); 66 } 67 68 #endif /* __ASM__ */ 69 45 70 #endif 46 71 -
kernel/arch/ppc32/src/cpu/cpu.c
r339249f r3500f75 34 34 35 35 #include <arch/cpu.h> 36 #include <arch/cpuid.h>37 36 #include <cpu.h> 38 37 #include <arch.h> … … 45 44 void cpu_identify(void) 46 45 { 47 cpu_info_t info; 48 49 cpu_version(&info); 50 CPU->arch.version = info.version; 51 CPU->arch.revision = info.revision; 46 cpu_version(&CPU->arch); 52 47 } 53 48 54 void cpu_print_report(cpu_t * m)49 void cpu_print_report(cpu_t *cpu) 55 50 { 56 51 const char *name; 57 52 58 switch ( m->arch.version) {53 switch (cpu->arch.version) { 59 54 case 8: 60 name = " (PowerPC 750)";55 name = "PowerPC 750"; 61 56 break; 62 57 case 9: 63 name = " (PowerPC 604e)";58 name = "PowerPC 604e"; 64 59 break; 65 60 case 0x81: 66 name = " (PowerPC 8260)";61 name = "PowerPC 8260"; 67 62 break; 68 63 case 0x8081: 69 name = " (PowerPC 826xA)";64 name = "PowerPC 826xA"; 70 65 break; 71 66 default: 72 name = " ";67 name = "unknown"; 73 68 } 74 69 75 printf("cpu%d: version=%d%s, revision=%d\n", m->id, m->arch.version, name, m->arch.revision); 70 printf("cpu%" PRIs ": version=%" PRIu16" (%s), revision=%" PRIu16 "\n", cpu->id, 71 cpu->arch.version, name, cpu->arch.revision); 76 72 } 77 73
Note:
See TracChangeset
for help on using the changeset viewer.