Changeset 48c1ef9 in mainline
- Timestamp:
- 2006-05-21T20:38:18Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 040542aa
- Parents:
- bd55bbb
- Location:
- arch
- Files:
-
- 26 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
arch/ppc32/include/asm/regname.h
rbd55bbb r48c1ef9 220 220 #define hid0_dci (1 << 10) 221 221 222 /* Cache sizes */223 #define L1_CACHE_LINES (128 * 8)224 #define L1_CACHE_BYTES 5225 226 222 #endif -
arch/ppc32/include/mm/asid.h
rbd55bbb r48c1ef9 27 27 */ 28 28 29 /*30 * ia32 has no hardware support for address space identifiers.31 * This file is provided to do nop-implementation of mm/asid.h32 * interface.33 */34 35 29 #ifndef __ppc32_ASID_H__ 36 30 #define __ppc32_ASID_H__ -
arch/ppc32/include/types.h
rbd55bbb r48c1ef9 34 34 typedef signed char __s8; 35 35 typedef signed short __s16; 36 typedef signed long__s32;36 typedef signed int __s32; 37 37 typedef signed long long __s64; 38 38 -
arch/ppc64/Makefile.inc
rbd55bbb r48c1ef9 39 39 # 40 40 41 CFLAGS += -mcpu=powerpc64 -m 6441 CFLAGS += -mcpu=powerpc64 -msoft-float -m64 42 42 AFLAGS += -a64 43 43 LFLAGS += -no-check-sections -N … … 57 57 58 58 ARCH_SOURCES = \ 59 arch/$(ARCH)/src/console.c \60 59 arch/$(ARCH)/src/context.S \ 61 60 arch/$(ARCH)/src/debug/panic.s \ … … 68 67 arch/$(ARCH)/src/asm.S \ 69 68 arch/$(ARCH)/src/cpu/cpu.c \ 69 arch/$(ARCH)/src/proc/scheduler.c \ 70 70 arch/$(ARCH)/src/ddi/ddi.c \ 71 arch/$(ARCH)/src/proc/scheduler.c \72 71 arch/$(ARCH)/src/mm/as.c \ 73 72 arch/$(ARCH)/src/mm/frame.c \ 74 73 arch/$(ARCH)/src/mm/memory_init.c \ 75 arch/$(ARCH)/src/mm/page.c 74 arch/$(ARCH)/src/mm/page.c \ 75 arch/$(ARCH)/src/mm/tlb.c -
arch/ppc64/include/asm.h
rbd55bbb r48c1ef9 40 40 * @return Old interrupt priority level. 41 41 */ 42 static inline ipl_t interrupts_enable(void) { 42 static inline ipl_t interrupts_enable(void) 43 { 43 44 ipl_t v; 44 45 ipl_t tmp; 45 46 46 __asm__volatile (47 asm volatile ( 47 48 "mfmsr %0\n" 48 49 "mfmsr %1\n" … … 61 62 * @return Old interrupt priority level. 62 63 */ 63 static inline ipl_t interrupts_disable(void) { 64 static inline ipl_t interrupts_disable(void) 65 { 64 66 ipl_t v; 65 67 ipl_t tmp; 66 68 67 __asm__volatile (69 asm volatile ( 68 70 "mfmsr %0\n" 69 71 "mfmsr %1\n" … … 81 83 * @param ipl Saved interrupt priority level. 82 84 */ 83 static inline void interrupts_restore(ipl_t ipl) { 85 static inline void interrupts_restore(ipl_t ipl) 86 { 84 87 ipl_t tmp; 85 88 86 __asm__volatile (89 asm volatile ( 87 90 "mfmsr %1\n" 88 91 "rlwimi %0, %1, 0, 17, 15\n" … … 93 96 : "=r" (ipl), "=r" (tmp) 94 97 : "0" (ipl) 98 : "cr0" 95 99 ); 96 100 } … … 102 106 * @return Current interrupt priority level. 103 107 */ 104 static inline ipl_t interrupts_read(void) { 108 static inline ipl_t interrupts_read(void) 109 { 105 110 ipl_t v; 106 __asm__ volatile ( 111 112 asm volatile ( 107 113 "mfmsr %0\n" 108 114 : "=r" (v) … … 121 127 __address v; 122 128 123 __asm__ volatile ("and %0, %%sp, %1\n" : "=r" (v) : "r" (~(STACK_SIZE-1))); 124 129 asm volatile ( 130 "and %0, %%sp, %1\n" 131 : "=r" (v) 132 : "r" (~(STACK_SIZE - 1)) 133 ); 125 134 return v; 126 135 } … … 133 142 void asm_delay_loop(__u32 t); 134 143 144 extern void userspace_asm(__address uspace_uarg, __address stack, __address entry); 145 135 146 #endif -
arch/ppc64/include/asm/regname.h
rbd55bbb r48c1ef9 195 195 #define msr_ir (1 << 4) 196 196 #define msr_dr (1 << 5) 197 #define msr_pr (1 << 14) 198 #define msr_ee (1 << 15) 197 199 198 200 /* HID0 bits */ -
arch/ppc64/include/atomic.h
rbd55bbb r48c1ef9 34 34 long tmp; 35 35 36 asm __volatile__(36 asm volatile ( 37 37 "1:\n" 38 38 "lwarx %0, 0, %2\n" … … 42 42 : "=&r" (tmp), "=m" (val->count) 43 43 : "r" (&val->count), "m" (val->count) 44 : "cc"); 44 : "cc" 45 ); 45 46 } 46 47 … … 49 50 long tmp; 50 51 51 asm __volatile__(52 asm volatile ( 52 53 "1:\n" 53 54 "lwarx %0, 0, %2\n" … … 57 58 : "=&r" (tmp), "=m" (val->count) 58 59 : "r" (&val->count), "m" (val->count) 59 : "cc"); 60 : "cc" 61 ); 60 62 } 61 63 -
arch/ppc64/include/barrier.h
rbd55bbb r48c1ef9 30 30 #define __ppc64_BARRIER_H__ 31 31 32 #define CS_ENTER_BARRIER() __asm__volatile ("" ::: "memory")33 #define CS_LEAVE_BARRIER() __asm__volatile ("" ::: "memory")32 #define CS_ENTER_BARRIER() asm volatile ("" ::: "memory") 33 #define CS_LEAVE_BARRIER() asm volatile ("" ::: "memory") 34 34 35 #define memory_barrier() __asm__volatile ("sync" ::: "memory")36 #define read_barrier() __asm__volatile ("sync" ::: "memory")37 #define write_barrier() __asm__volatile ("eieio" ::: "memory")35 #define memory_barrier() asm volatile ("sync" ::: "memory") 36 #define read_barrier() asm volatile ("sync" ::: "memory") 37 #define write_barrier() asm volatile ("eieio" ::: "memory") 38 38 39 39 #endif -
arch/ppc64/include/boot/boot.h
rbd55bbb r48c1ef9 35 35 #define TEMP_STACK_SIZE 0x100 36 36 37 #define TASKMAP_MAX_RECORDS 32 37 38 #define MEMMAP_MAX_RECORDS 32 38 39 … … 42 43 43 44 typedef struct { 45 __address addr; 46 __u64 size; 47 } utask_t; 48 49 typedef struct { 50 __u32 count; 51 utask_t tasks[TASKMAP_MAX_RECORDS]; 52 } taskmap_t; 53 54 typedef struct { 44 55 __address start; 45 __u 32size;56 __u64 size; 46 57 } memzone_t; 47 58 48 59 typedef struct { 49 __u 32total;60 __u64 total; 50 61 __u32 count; 51 62 memzone_t zones[MEMMAP_MAX_RECORDS]; … … 61 72 62 73 typedef struct { 74 taskmap_t taskmap; 63 75 memmap_t memmap; 64 76 screen_t screen; -
arch/ppc64/include/byteorder.h
rbd55bbb r48c1ef9 54 54 __address v; 55 55 56 __asm__ volatile ("lwbrx %0, %1, %2\n" : "=r" (v) : "i" (0) , "r" (&n)); 57 56 asm volatile ( 57 "lwbrx %0, %1, %2\n" 58 : "=r" (v) 59 : "i" (0), "r" (&n) 60 ); 58 61 return v; 59 62 } 63 60 64 #endif -
arch/ppc64/include/cpuid.h
rbd55bbb r48c1ef9 39 39 static inline void cpu_version(struct cpu_info *info) 40 40 { 41 __asm__volatile (42 "mf spr %0, 287\n"41 asm volatile ( 42 "mfpvr %0\n" 43 43 : "=r" (*info) 44 44 ); -
arch/ppc64/include/elf.h
rbd55bbb r48c1ef9 30 30 #define __ppc64_ELF_H__ 31 31 32 #define ELF_MACHINE EM_PPC 32 #define ELF_MACHINE EM_PPC64 33 33 #define ELF_DATA_ENCODING ELFDATA2MSB 34 34 #define ELF_CLASS ELFCLASS32 -
arch/ppc64/include/exception.h
rbd55bbb r48c1ef9 1 1 /* 2 * Copyright (C) 200 5 Jakub Jermar2 * Copyright (C) 2006 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef __ppc64_ CONSOLE_H__30 #define __ppc64_ CONSOLE_H__29 #ifndef __ppc64_EXCEPTION_H__ 30 #define __ppc64_EXCEPTION_H__ 31 31 32 extern void ppc64_console_init(void); 32 #ifndef __ppc64_TYPES_H__ 33 # include <arch/types.h> 34 #endif 35 36 #include <typedefs.h> 37 38 struct istate { 39 __u64 r0; 40 __u64 r2; 41 __u64 r3; 42 __u64 r4; 43 __u64 r5; 44 __u64 r6; 45 __u64 r7; 46 __u64 r8; 47 __u64 r9; 48 __u64 r10; 49 __u64 r11; 50 __u64 r13; 51 __u64 r14; 52 __u64 r15; 53 __u64 r16; 54 __u64 r17; 55 __u64 r18; 56 __u64 r19; 57 __u64 r20; 58 __u64 r21; 59 __u64 r22; 60 __u64 r23; 61 __u64 r24; 62 __u64 r25; 63 __u64 r26; 64 __u64 r27; 65 __u64 r28; 66 __u64 r29; 67 __u64 r30; 68 __u64 r31; 69 __u64 cr; 70 __u64 pc; 71 __u64 srr1; 72 __u64 lr; 73 __u64 ctr; 74 __u64 xer; 75 __u64 r12; 76 __u64 sp; 77 }; 78 79 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 80 { 81 istate->pc = retaddr; 82 } 33 83 34 84 #endif -
arch/ppc64/include/mm/asid.h
rbd55bbb r48c1ef9 32 32 typedef int asid_t; 33 33 34 #define ASID_MAX_ARCH 334 #define ASID_MAX_ARCH 3 35 35 36 #define asid_get() (ASID_START+1)36 #define asid_get() (ASID_START+1) 37 37 38 38 #endif -
arch/ppc64/include/mm/frame.h
rbd55bbb r48c1ef9 31 31 32 32 #define FRAME_WIDTH 12 /* 4K */ 33 #define FRAME_SIZE (1 <<FRAME_WIDTH)33 #define FRAME_SIZE (1 << FRAME_WIDTH) 34 34 35 35 #ifdef KERNEL 36 36 #ifndef __ASM__ 37 38 #include <arch/types.h> 39 40 extern __address last_frame; 37 41 38 42 extern void frame_arch_init(void); -
arch/ppc64/include/mm/page.h
rbd55bbb r48c1ef9 45 45 #endif 46 46 47 #define PTL0_ENTRIES_ARCH 0 48 #define PTL1_ENTRIES_ARCH 0 49 #define PTL2_ENTRIES_ARCH 0 50 #define PTL3_ENTRIES_ARCH 0 47 /* 48 * Implementation of generic 4-level page table interface, 49 * the hardware Page Hash Table is used as cache. 50 * 51 * Page table layout: 52 * - 32-bit virtual addressess 53 * - Offset is 12 bits => pages are 4K long 54 * - PTL0 has 1024 entries (10 bits) 55 * - PTL1 is not used 56 * - PTL2 is not used 57 * - PLT3 has 1024 entries (10 bits) 58 */ 51 59 52 #define PTL0_INDEX_ARCH(vaddr) 0 53 #define PTL1_INDEX_ARCH(vaddr) 0 54 #define PTL2_INDEX_ARCH(vaddr) 0 55 #define PTL3_INDEX_ARCH(vaddr) 0 60 #define PTL0_ENTRIES_ARCH 1024 61 #define PTL1_ENTRIES_ARCH 0 62 #define PTL2_ENTRIES_ARCH 0 63 #define PTL3_ENTRIES_ARCH 1024 64 65 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff) 66 #define PTL1_INDEX_ARCH(vaddr) 0 67 #define PTL2_INDEX_ARCH(vaddr) 0 68 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff) 69 70 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *) (ptl0))[(i)].pfn << 12) 71 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 72 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 73 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *) (ptl3))[(i)].pfn << 12) 56 74 57 75 #define SET_PTL0_ADDRESS_ARCH(ptl0) 58 59 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) 0) 60 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) ((pte_t *) 0) 61 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) ((pte_t *) 0) 62 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((pte_t *) 0) 63 64 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) 76 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 65 77 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 66 78 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 67 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) 79 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 68 80 69 #define GET_PTL1_FLAGS_ARCH(ptl0, i) 070 #define GET_PTL2_FLAGS_ARCH(ptl1, i) 071 #define GET_PTL3_FLAGS_ARCH(ptl2, i) 072 #define GET_FRAME_FLAGS_ARCH(ptl3, i) 081 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 82 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 83 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 84 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 73 85 74 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) 86 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 75 87 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 76 88 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 77 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) 89 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 78 90 79 #define PTE_VALID_ARCH(p ) 180 #define PTE_PRESENT_ARCH(p ) 181 #define PTE_GET_FRAME_ARCH(p ) 091 #define PTE_VALID_ARCH(pte) (*((__u32 *) (pte)) != 0) 92 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) 93 #define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn << 12) 82 94 83 95 #ifndef __ASM__ … … 87 99 #include <arch/types.h> 88 100 101 static inline int get_pt_flags(pte_t *pt, index_t i) 102 { 103 pte_t *p = &pt[i]; 104 105 return ( 106 (1 << PAGE_CACHEABLE_SHIFT) | 107 ((!p->p) << PAGE_PRESENT_SHIFT) | 108 (1 << PAGE_USER_SHIFT) | 109 (1 << PAGE_READ_SHIFT) | 110 (1 << PAGE_WRITE_SHIFT) | 111 (1 << PAGE_EXEC_SHIFT) | 112 (p->g << PAGE_GLOBAL_SHIFT) 113 ); 114 } 115 116 static inline void set_pt_flags(pte_t *pt, index_t i, int flags) 117 { 118 pte_t *p = &pt[i]; 119 120 p->p = !(flags & PAGE_NOT_PRESENT); 121 p->g = (flags & PAGE_GLOBAL) != 0; 122 p->valid = 1; 123 } 124 89 125 extern void page_arch_init(void); 126 127 #define PHT_BITS 16 128 #define PHT_ORDER 4 129 130 typedef struct { 131 unsigned v : 1; /**< Valid */ 132 unsigned vsid : 24; /**< Virtual Segment ID */ 133 unsigned h : 1; /**< Primary/secondary hash */ 134 unsigned api : 6; /**< Abbreviated Page Index */ 135 unsigned rpn : 20; /**< Real Page Number */ 136 unsigned reserved0 : 3; 137 unsigned r : 1; /**< Reference */ 138 unsigned c : 1; /**< Change */ 139 unsigned wimg : 4; /**< Access control */ 140 unsigned reserved1 : 1; 141 unsigned pp : 2; /**< Page protection */ 142 } phte_t; 143 144 extern void pht_refill(bool data, istate_t *istate); 145 extern void pht_init(void); 90 146 91 147 #endif /* __ASM__ */ -
arch/ppc64/include/mm/tlb.h
rbd55bbb r48c1ef9 30 30 #define __ppc64_TLB_H__ 31 31 32 #define tlb_arch_init()33 #define tlb_print()34 32 35 33 #endif -
arch/ppc64/include/types.h
rbd55bbb r48c1ef9 34 34 typedef signed char __s8; 35 35 typedef signed short __s16; 36 typedef signed long__s32;37 typedef signed long long__s64;36 typedef signed int __s32; 37 typedef signed long __s64; 38 38 39 39 typedef unsigned char __u8; … … 43 43 44 44 typedef __u64 __address; 45 typedef __u 32pfn_t;45 typedef __u64 pfn_t; 46 46 47 47 typedef __u64 ipl_t; 48 48 49 typedef __u 64__native;49 typedef __u32 __native; 50 50 51 typedef __u32 pte_t; 51 /** Page Table Entry. */ 52 typedef struct { 53 unsigned p : 1; /**< Present bit. */ 54 unsigned a : 1; /**< Accessed bit. */ 55 unsigned g : 1; /**< Global bit. */ 56 unsigned valid : 1; /**< Valid content even if not present. */ 57 unsigned pfn : 20; /**< Physical frame number. */ 58 } pte_t; 52 59 53 60 #endif -
arch/ppc64/src/asm.S
rbd55bbb r48c1ef9 31 31 .text 32 32 33 .global userspace_asm 33 34 .global iret 35 .global iret_syscall 34 36 .global memsetb 35 37 .global memcpy 38 .global memcpy_from_uspace 39 .global memcpy_to_uspace 40 .global memcpy_from_uspace_failover_address 41 .global memcpy_to_uspace_failover_address 42 43 userspace_asm: 44 45 # r3 = uspace_uarg 46 # r4 = stack 47 # r5 = entry 48 49 # disable interrupts 50 51 mfmsr r31 52 rlwinm r31, r31, 0, 17, 15 53 mtmsr r31 54 55 # set entry point 56 57 mtsrr0 r5 58 59 # set problem state, enable interrupts 60 61 ori r31, r31, msr_pr 62 ori r31, r31, msr_ee 63 mtsrr1 r31 64 65 # set stack 66 67 mr sp, r4 68 69 # jump to userspace 70 71 rfi 36 72 37 73 iret: 38 lwz r3, 144(sp) 39 mtxer r3 40 41 lwz r3, 140(sp) 42 mtctr r3 43 44 lwz r3, 136(sp) 45 mtcr r3 46 47 lwz r3, 132(sp) 48 mtlr r3 49 50 lwz r3, 128(sp) 51 mtspr srr1, r3 52 53 lwz r3, 124(sp) 54 mtspr srr0, r3 55 56 lwz r0, 0(sp) 57 lwz r2, 4(sp) 58 lwz r3, 8(sp) 59 lwz r4, 12(sp) 60 lwz r5, 16(sp) 61 lwz r6, 20(sp) 62 lwz r7, 24(sp) 63 lwz r8, 28(sp) 64 lwz r9, 32(sp) 65 lwz r10, 36(sp) 66 lwz r11, 40(sp) 67 lwz r12, 44(sp) 68 lwz r13, 48(sp) 69 lwz r14, 52(sp) 70 lwz r15, 56(sp) 71 lwz r16, 60(sp) 72 lwz r17, 64(sp) 73 lwz r18, 68(sp) 74 lwz r19, 72(sp) 75 lwz r20, 76(sp) 76 lwz r21, 80(sp) 77 lwz r22, 84(sp) 78 lwz r23, 88(sp) 79 lwz r24, 92(sp) 80 lwz r25, 96(sp) 81 lwz r26, 100(sp) 82 lwz r27, 104(sp) 83 lwz r28, 108(sp) 84 lwz r29, 112(sp) 85 lwz r30, 116(sp) 86 lwz r31, 120(sp) 87 88 mfspr sp, sprg1 89 74 75 # disable interrupts 76 77 mfmsr r31 78 rlwinm r31, r31, 0, 17, 15 79 mtmsr r31 80 81 lwz r0, 8(sp) 82 lwz r2, 12(sp) 83 lwz r3, 16(sp) 84 lwz r4, 20(sp) 85 lwz r5, 24(sp) 86 lwz r6, 28(sp) 87 lwz r7, 32(sp) 88 lwz r8, 36(sp) 89 lwz r9, 40(sp) 90 lwz r10, 44(sp) 91 lwz r11, 48(sp) 92 lwz r13, 52(sp) 93 lwz r14, 56(sp) 94 lwz r15, 60(sp) 95 lwz r16, 64(sp) 96 lwz r17, 68(sp) 97 lwz r18, 72(sp) 98 lwz r19, 76(sp) 99 lwz r20, 80(sp) 100 lwz r21, 84(sp) 101 lwz r22, 88(sp) 102 lwz r23, 92(sp) 103 lwz r24, 96(sp) 104 lwz r25, 100(sp) 105 lwz r26, 104(sp) 106 lwz r27, 108(sp) 107 lwz r28, 112(sp) 108 lwz r29, 116(sp) 109 lwz r30, 120(sp) 110 lwz r31, 124(sp) 111 112 lwz r12, 128(sp) 113 mtcr r12 114 115 lwz r12, 132(sp) 116 mtsrr0 r12 117 118 lwz r12, 136(sp) 119 mtsrr1 r12 120 121 lwz r12, 140(sp) 122 mtlr r12 123 124 lwz r12, 144(sp) 125 mtctr r12 126 127 lwz r12, 148(sp) 128 mtxer r12 129 130 lwz r12, 152(sp) 131 lwz sp, 156(sp) 132 133 rfi 134 135 iret_syscall: 136 137 # reset decrementer 138 139 li r31, 1000 140 mtdec r31 141 142 # disable interrupts 143 144 mfmsr r31 145 rlwinm r31, r31, 0, 17, 15 146 mtmsr r31 147 148 lwz r0, 8(sp) 149 lwz r2, 12(sp) 150 lwz r4, 20(sp) 151 lwz r5, 24(sp) 152 lwz r6, 28(sp) 153 lwz r7, 32(sp) 154 lwz r8, 36(sp) 155 lwz r9, 40(sp) 156 lwz r10, 44(sp) 157 lwz r11, 48(sp) 158 lwz r13, 52(sp) 159 lwz r14, 56(sp) 160 lwz r15, 60(sp) 161 lwz r16, 64(sp) 162 lwz r17, 68(sp) 163 lwz r18, 72(sp) 164 lwz r19, 76(sp) 165 lwz r20, 80(sp) 166 lwz r21, 84(sp) 167 lwz r22, 88(sp) 168 lwz r23, 92(sp) 169 lwz r24, 96(sp) 170 lwz r25, 100(sp) 171 lwz r26, 104(sp) 172 lwz r27, 108(sp) 173 lwz r28, 112(sp) 174 lwz r29, 116(sp) 175 lwz r30, 120(sp) 176 lwz r31, 124(sp) 177 178 lwz r12, 128(sp) 179 mtcr r12 180 181 lwz r12, 132(sp) 182 mtsrr0 r12 183 184 lwz r12, 136(sp) 185 mtsrr1 r12 186 187 lwz r12, 140(sp) 188 mtlr r12 189 190 lwz r12, 144(sp) 191 mtctr r12 192 193 lwz r12, 148(sp) 194 mtxer r12 195 196 lwz r12, 152(sp) 197 lwz sp, 156(sp) 198 90 199 rfi 91 200 … … 134 243 135 244 memcpy: 245 memcpy_from_uspace: 246 memcpy_to_uspace: 247 136 248 srwi. r7, r5, 3 137 249 addi r6, r3, -4 … … 194 306 mtctr r7 195 307 b 1b 308 309 memcpy_from_uspace_failover_address: 310 memcpy_to_uspace_failover_address: 311 b memcpy_from_uspace_failover_address -
arch/ppc64/src/boot/boot.S
rbd55bbb r48c1ef9 35 35 kernel_image_start: 36 36 37 # load tempora rystack37 # load temporal kernel stack 38 38 39 lis sp, end_stack@ha 40 addi sp, sp, end_stack@l 39 lis sp, kernel_stack@ha 40 addi sp, sp, kernel_stack@l 41 42 # set kernel stack for interrupt handling 43 44 mr r31, sp 45 subis r31, r31, 0x8000 46 mtsprg0 r31 41 47 42 48 # r3 contains physical address of bootinfo_t 43 49 # r4 contains size of bootinfo_t 44 50 45 lis r31, 0x80000000@ha 46 addi r31, r31, 0x80000000@l 47 48 add r3, r3, r31 51 addis r3, r3, 0x8000 49 52 50 53 lis r31, bootinfo@ha … … 68 71 bootinfo_end: 69 72 73 bl arch_pre_main 70 74 b main_bsp 71 75 72 76 .section K_DATA_START, "aw", @progbits 73 77 78 .align 12 79 kernel_stack_bottom: 74 80 .space TEMP_STACK_SIZE 75 end_stack:81 kernel_stack: -
arch/ppc64/src/dummy.s
rbd55bbb r48c1ef9 29 29 .text 30 30 31 .global cpu_halt32 31 .global asm_delay_loop 33 .global userspace34 32 .global sys_tls_set 35 .global tlb_invalidate_all36 .global tlb_invalidate_asid37 .global tlb_invalidate_pages38 39 cpu_halt:40 b cpu_halt41 42 tlb_invalidate_all:43 b tlb_invalidate_all44 45 tlb_invalidate_asid:46 b tlb_invalidate_asid47 48 tlb_invalidate_pages:49 b tlb_invalidate_pages50 51 userspace:52 b userspace53 33 54 34 sys_tls_set: -
arch/ppc64/src/exception.S
rbd55bbb r48c1ef9 32 32 .section K_UNMAPPED_TEXT_START, "ax" 33 33 34 .macro CONTEXT_STORE 35 36 # save R12 in SPRG1, backup CR in R12 37 # save SP in SPRG2 38 39 mtsprg1 r12 40 mfcr r12 41 mtsprg2 sp 42 43 # check whether SP is in kernel 44 45 andis. sp, sp, 0x8000 46 bne 1f 47 48 # stack is in user-space 49 50 mfsprg0 sp 51 52 b 2f 53 54 1: 55 56 # stack is in kernel 57 58 mfsprg2 sp 59 subis sp, sp, 0x8000 60 61 2: 62 63 subi sp, sp, 160 64 stw r0, 8(sp) 65 stw r2, 12(sp) 66 stw r3, 16(sp) 67 stw r4, 20(sp) 68 stw r5, 24(sp) 69 stw r6, 28(sp) 70 stw r7, 32(sp) 71 stw r8, 36(sp) 72 stw r9, 40(sp) 73 stw r10, 44(sp) 74 stw r11, 48(sp) 75 stw r13, 52(sp) 76 stw r14, 56(sp) 77 stw r15, 60(sp) 78 stw r16, 64(sp) 79 stw r17, 68(sp) 80 stw r18, 72(sp) 81 stw r19, 76(sp) 82 stw r20, 80(sp) 83 stw r21, 84(sp) 84 stw r22, 88(sp) 85 stw r23, 92(sp) 86 stw r24, 96(sp) 87 stw r25, 100(sp) 88 stw r26, 104(sp) 89 stw r27, 108(sp) 90 stw r28, 112(sp) 91 stw r29, 116(sp) 92 stw r30, 120(sp) 93 stw r31, 124(sp) 94 95 stw r12, 128(sp) 96 97 mfsrr0 r12 98 stw r12, 132(sp) 99 100 mfsrr1 r12 101 stw r12, 136(sp) 102 103 mflr r12 104 stw r12, 140(sp) 105 106 mfctr r12 107 stw r12, 144(sp) 108 109 mfxer r12 110 stw r12, 148(sp) 111 112 mfsprg1 r12 113 stw r12, 152(sp) 114 115 mfsprg2 r12 116 stw r12, 156(sp) 117 .endm 118 119 .org 0x060 120 jump_to_kernel: 121 lis r12, iret@ha 122 addi r12, r12, iret@l 123 mtlr r12 124 125 mfmsr r12 126 ori r12, r12, (msr_ir | msr_dr)@l 127 mtsrr1 r12 128 129 addis sp, sp, 0x8000 130 mr r4, sp 131 addi r4, r4, 8 132 133 rfi 134 135 jump_to_kernel_syscall: 136 lis r12, syscall_handler@ha 137 addi r12, r12, syscall_handler@l 138 mtsrr0 r12 139 140 lis r12, iret_syscall@ha 141 addi r12, r12, iret_syscall@l 142 mtlr r12 143 144 mfmsr r12 145 ori r12, r12, (msr_ir | msr_dr)@l 146 mtsrr1 r12 147 148 addis sp, sp, 0x8000 149 rfi 150 34 151 .org 0x100 35 152 .global exc_system_reset … … 45 162 .global exc_data_storage 46 163 exc_data_storage: 47 b exc_data_storage 48 49 .org 0x380 50 .global exc_data_segment 51 exc_data_segment: 52 b exc_data_segment 164 CONTEXT_STORE 165 166 lis r12, pht_refill@ha 167 addi r12, r12, pht_refill@l 168 mtsrr0 r12 169 170 li r3, 1 171 b jump_to_kernel 53 172 54 173 .org 0x400 55 174 .global exc_instruction_storage 56 175 exc_instruction_storage: 57 b exc_instruction_storage 58 59 .org 0x480 60 .global exc_instruction_segment 61 exc_instruction_segment: 62 b exc_instruction_segment 176 CONTEXT_STORE 177 178 lis r12, pht_refill@ha 179 addi r12, r12, pht_refill@l 180 mtsrr0 r12 181 182 li r3, 0 183 b jump_to_kernel 63 184 64 185 .org 0x500 … … 85 206 .global exc_decrementer 86 207 exc_decrementer: 87 mtspr sprg1, sp 88 89 subis sp, sp, 0x8000 90 91 subi sp, sp, 144 92 stw r0, 0(sp) 93 stw r2, 4(sp) 94 stw r3, 8(sp) 95 stw r4, 12(sp) 96 stw r5, 16(sp) 97 stw r6, 20(sp) 98 stw r7, 24(sp) 99 stw r8, 28(sp) 100 stw r9, 32(sp) 101 stw r10, 36(sp) 102 stw r11, 40(sp) 103 stw r12, 44(sp) 104 stw r13, 48(sp) 105 stw r14, 52(sp) 106 stw r15, 56(sp) 107 stw r16, 60(sp) 108 stw r17, 64(sp) 109 stw r18, 68(sp) 110 stw r19, 72(sp) 111 stw r20, 76(sp) 112 stw r21, 80(sp) 113 stw r22, 84(sp) 114 stw r23, 88(sp) 115 stw r24, 92(sp) 116 stw r25, 96(sp) 117 stw r26, 100(sp) 118 stw r27, 104(sp) 119 stw r28, 108(sp) 120 stw r29, 112(sp) 121 stw r30, 116(sp) 122 stw r31, 120(sp) 123 124 mfspr r3, srr0 125 stw r3, 124(sp) 126 127 mfspr r3, srr1 128 stw r3, 128(sp) 129 130 mflr r3 131 stw r3, 132(sp) 132 133 mfcr r3 134 stw r3, 136(sp) 135 136 mfctr r3 137 stw r3, 140(sp) 138 139 mfxer r3 140 stw r3, 144(sp) 141 142 lis r3, exc_dispatch@ha 143 addi r3, r3, exc_dispatch@l 144 mtspr srr0, r3 145 146 mfmsr r3 147 ori r3, r3, (msr_ir | msr_dr)@l 148 mtspr srr1, r3 149 150 lis r3, iret@ha 151 addi r3, r3, iret@l 152 mtlr r3 153 154 addis sp, sp, 0x8000 208 CONTEXT_STORE 209 210 lis r12, exc_dispatch@ha 211 addi r12, r12, exc_dispatch@l 212 mtsrr0 r12 213 155 214 li r3, 10 156 rfid215 b jump_to_kernel 157 216 158 217 .org 0xa00 … … 169 228 .global exc_syscall 170 229 exc_syscall: 171 b exc_syscall 230 CONTEXT_STORE 231 232 b jump_to_kernel_syscall 172 233 173 234 .org 0xd00 -
arch/ppc64/src/interrupt.c
rbd55bbb r48c1ef9 32 32 #include <arch.h> 33 33 #include <time/clock.h> 34 #include < print.h>34 #include <ipc/sysipc.h> 35 35 36 36 … … 39 39 asm volatile ( 40 40 "mtdec %0\n" 41 :: "r" (1000) 41 : 42 : "r" (1000) 42 43 ); 43 44 } … … 56 57 exc_register(VECTOR_DECREMENTER, "timer", exception_decrementer); 57 58 } 59 60 61 /* Reregister irq to be IPC-ready */ 62 void irq_ipc_bind_arch(__native irq) 63 { 64 panic("not implemented\n"); 65 /* TODO */ 66 } -
arch/ppc64/src/mm/memory_init.c
rbd55bbb r48c1ef9 44 44 45 45 for (i = 0; i < bootinfo.memmap.count; i++) 46 printf("base: % psize: %#x\n", bootinfo.memmap.zones[i].start, bootinfo.memmap.zones[i].size);46 printf("base: %#x size: %#x\n", bootinfo.memmap.zones[i].start, bootinfo.memmap.zones[i].size); 47 47 } -
arch/ppc64/src/mm/page.c
rbd55bbb r48c1ef9 30 30 #include <genarch/mm/page_pt.h> 31 31 #include <arch/mm/frame.h> 32 #include <arch/asm.h> 32 33 #include <mm/frame.h> 33 34 #include <mm/page.h> 35 #include <mm/as.h> 36 #include <arch.h> 34 37 #include <arch/types.h> 38 #include <arch/exception.h> 39 #include <align.h> 40 #include <config.h> 41 #include <print.h> 42 #include <symtab.h> 43 44 static phte_t *phte; 45 46 47 /** Try to find PTE for faulting address 48 * 49 * Try to find PTE for faulting address. 50 * The as->lock must be held on entry to this function 51 * if lock is true. 52 * 53 * @param as Address space. 54 * @param lock Lock/unlock the address space. 55 * @param badvaddr Faulting virtual address. 56 * @param istate Pointer to interrupted state. 57 * @param pfrc Pointer to variable where as_page_fault() return code will be stored. 58 * @return PTE on success, NULL otherwise. 59 * 60 */ 61 static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, istate_t *istate, int *pfcr) 62 { 63 /* 64 * Check if the mapping exists in page tables. 65 */ 66 pte_t *pte = page_mapping_find(as, badvaddr); 67 if ((pte) && (pte->p)) { 68 /* 69 * Mapping found in page tables. 70 * Immediately succeed. 71 */ 72 return pte; 73 } else { 74 int rc; 75 76 /* 77 * Mapping not found in page tables. 78 * Resort to higher-level page fault handler. 79 */ 80 page_table_unlock(as, lock); 81 switch (rc = as_page_fault(badvaddr, istate)) { 82 case AS_PF_OK: 83 /* 84 * The higher-level page fault handler succeeded, 85 * The mapping ought to be in place. 86 */ 87 page_table_lock(as, lock); 88 pte = page_mapping_find(as, badvaddr); 89 ASSERT((pte) && (pte->p)); 90 return pte; 91 case AS_PF_DEFER: 92 page_table_lock(as, lock); 93 *pfcr = rc; 94 return NULL; 95 case AS_PF_FAULT: 96 page_table_lock(as, lock); 97 printf("Page fault.\n"); 98 *pfcr = rc; 99 return NULL; 100 default: 101 panic("unexpected rc (%d)\n", rc); 102 } 103 } 104 } 105 106 107 static void pht_refill_fail(__address badvaddr, istate_t *istate) 108 { 109 char *symbol = ""; 110 char *sym2 = ""; 111 112 char *s = get_symtab_entry(istate->pc); 113 if (s) 114 symbol = s; 115 s = get_symtab_entry(istate->lr); 116 if (s) 117 sym2 = s; 118 panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, istate->pc, symbol, sym2); 119 } 120 121 122 static void pht_insert(const __address vaddr, const pfn_t pfn) 123 { 124 __u32 page = (vaddr >> 12) & 0xffff; 125 __u32 api = (vaddr >> 22) & 0x3f; 126 __u32 vsid; 127 128 asm volatile ( 129 "mfsrin %0, %1\n" 130 : "=r" (vsid) 131 : "r" (vaddr) 132 ); 133 134 /* Primary hash (xor) */ 135 __u32 h = 0; 136 __u32 hash = vsid ^ page; 137 __u32 base = (hash & 0x3ff) << 3; 138 __u32 i; 139 bool found = false; 140 141 /* Find unused or colliding 142 PTE in PTEG */ 143 for (i = 0; i < 8; i++) { 144 if ((!phte[base + i].v) || ((phte[base + i].vsid == vsid) && (phte[base + i].api == api))) { 145 found = true; 146 break; 147 } 148 } 149 150 if (!found) { 151 /* Secondary hash (not) */ 152 __u32 base2 = (~hash & 0x3ff) << 3; 153 154 /* Find unused or colliding 155 PTE in PTEG */ 156 for (i = 0; i < 8; i++) { 157 if ((!phte[base2 + i].v) || ((phte[base2 + i].vsid == vsid) && (phte[base2 + i].api == api))) { 158 found = true; 159 base = base2; 160 h = 1; 161 break; 162 } 163 } 164 165 if (!found) { 166 // TODO: A/C precedence groups 167 i = page % 8; 168 } 169 } 170 171 phte[base + i].v = 1; 172 phte[base + i].vsid = vsid; 173 phte[base + i].h = h; 174 phte[base + i].api = api; 175 phte[base + i].rpn = pfn; 176 phte[base + i].r = 0; 177 phte[base + i].c = 0; 178 phte[base + i].pp = 2; // FIXME 179 } 180 181 182 /** Process Instruction/Data Storage Interrupt 183 * 184 * @param data True if Data Storage Interrupt. 185 * @param istate Interrupted register context. 186 * 187 */ 188 void pht_refill(bool data, istate_t *istate) 189 { 190 __address badvaddr; 191 pte_t *pte; 192 int pfcr; 193 as_t *as; 194 bool lock; 195 196 if (AS == NULL) { 197 as = AS_KERNEL; 198 lock = false; 199 } else { 200 as = AS; 201 lock = true; 202 } 203 204 if (data) { 205 asm volatile ( 206 "mfdar %0\n" 207 : "=r" (badvaddr) 208 ); 209 } else 210 badvaddr = istate->pc; 211 212 page_table_lock(as, lock); 213 214 pte = find_mapping_and_check(as, lock, badvaddr, istate, &pfcr); 215 if (!pte) { 216 switch (pfcr) { 217 case AS_PF_FAULT: 218 goto fail; 219 break; 220 case AS_PF_DEFER: 221 /* 222 * The page fault came during copy_from_uspace() 223 * or copy_to_uspace(). 224 */ 225 page_table_unlock(as, lock); 226 return; 227 default: 228 panic("Unexpected pfrc (%d)\n", pfcr); 229 } 230 } 231 232 pte->a = 1; /* Record access to PTE */ 233 pht_insert(badvaddr, pte->pfn); 234 235 page_table_unlock(as, lock); 236 return; 237 238 fail: 239 page_table_unlock(as, lock); 240 pht_refill_fail(badvaddr, istate); 241 } 242 243 244 void pht_init(void) 245 { 246 memsetb((__address) phte, 1 << PHT_BITS, 0); 247 } 248 35 249 36 250 void page_arch_init(void) 37 251 { 38 page_mapping_operations = &pt_mapping_operations; 39 } 252 if (config.cpu_active == 1) { 253 page_mapping_operations = &pt_mapping_operations; 254 255 __address cur; 256 int flags; 257 258 /* Frames below 128 MB are mapped using BAT, 259 map rest of the physical memory */ 260 for (cur = 128 << 20; cur < last_frame; cur += FRAME_SIZE) { 261 flags = PAGE_CACHEABLE; 262 if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) 263 flags |= PAGE_GLOBAL; 264 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 265 } 266 267 /* Allocate page hash table */ 268 phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC)); 269 phte = (phte_t *) PA2KA((__address) physical_phte); 270 271 ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0); 272 pht_init(); 273 274 asm volatile ( 275 "mtsdr1 %0\n" 276 : 277 : "r" ((__address) physical_phte) 278 ); 279 } 280 } 281 282 283 __address hw_map(__address physaddr, size_t size) 284 { 285 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 286 panic("Unable to map physical memory %p (%d bytes)", physaddr, size) 287 288 __address virtaddr = PA2KA(last_frame); 289 pfn_t i; 290 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) 291 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); 292 293 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); 294 295 return virtaddr; 296 } -
arch/ppc64/src/mm/tlb.c
rbd55bbb r48c1ef9 1 1 /* 2 * Copyright (C) 200 5 Jakub Jermar2 * Copyright (C) 2006 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <arch/boot/boot.h> 30 #include <arch/console.h> 31 #include <console/chardev.h> 32 #include <console/console.h> 33 #include <genarch/fb/fb.h> 29 #include <mm/tlb.h> 34 30 35 31 36 /** Initialize console to use frame buffer. */ 37 void ppc64_console_init(void) 32 /** Initialize Page Hash Table. 33 * 34 * Setup the Page Hash Table with no entries. 35 * 36 */ 37 void tlb_arch_init(void) 38 38 { 39 /* TODO: Framebuffer mapping */ 40 fb_init(0xf0000000 + (bootinfo.screen.addr & ((__address) ~0 >> 15)), bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline); 39 tlb_invalidate_all(); 41 40 } 41 42 43 void tlb_invalidate_all(void) 44 { 45 asm volatile ( 46 "tlbia\n" 47 "tlbsync\n" 48 ); 49 } 50 51 52 /** Invalidate all entries in TLB that belong to specified address space. 53 * 54 * @param asid This parameter is ignored as the architecture doesn't support it. 55 */ 56 void tlb_invalidate_asid(asid_t asid) 57 { 58 tlb_invalidate_all(); 59 } 60 61 /** Invalidate TLB entries for specified page range belonging to specified address space. 62 * 63 * @param asid This parameter is ignored as the architecture doesn't support it. 64 * @param page Address of the first page whose entry is to be invalidated. 65 * @param cnt Number of entries to invalidate. 66 */ 67 void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt) 68 { 69 tlb_invalidate_all(); 70 } 71 72 73 74 /** Print contents of Page Hash Table. */ 75 void tlb_print(void) 76 { 77 } -
arch/ppc64/src/ppc64.c
rbd55bbb r48c1ef9 29 29 #include <arch.h> 30 30 #include <arch/boot/boot.h> 31 #include <arch/console.h>32 31 #include <arch/mm/memory_init.h> 33 32 #include <arch/interrupt.h> 34 #include <mm/frame.h> 33 #include <genarch/fb/fb.h> 34 #include <userspace.h> 35 #include <proc/uarg.h> 35 36 36 37 bootinfo_t bootinfo; 38 39 void arch_pre_main(void) 40 { 41 /* Setup usermode */ 42 init.cnt = bootinfo.taskmap.count; 43 44 __u32 i; 45 46 for (i = 0; i < bootinfo.taskmap.count; i++) { 47 init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); 48 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 49 } 50 } 37 51 38 52 void arch_pre_mm_init(void) … … 43 57 /* Start decrementer */ 44 58 start_decrementer(); 45 46 ppc64_console_init();47 59 } 48 60 … … 50 62 { 51 63 if (config.cpu_active == 1) { 64 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline); 65 52 66 /* Merge all zones to 1 big zone */ 53 67 zone_merge_all(); … … 68 82 } 69 83 84 void userspace(uspace_arg_t *kernel_uarg) 85 { 86 userspace_asm((__address) kernel_uarg->uspace_uarg, (__address) kernel_uarg->uspace_stack + THREAD_STACK_SIZE - SP_DELTA, (__address) kernel_uarg->uspace_entry); 87 88 /* Unreachable */ 89 for (;;) 90 ; 91 } -
arch/ppc64/src/proc/scheduler.c
rbd55bbb r48c1ef9 28 28 29 29 #include <arch/mm/page.h> 30 #include <arch/boot/boot.h> 30 31 #include <proc/scheduler.h> 31 32 #include <proc/thread.h> 32 33 #include <arch.h> 33 34 __address supervisor_sp;35 __address supervisor_sp_physical;36 34 37 35 /** Perform ppc64 specific tasks needed before the new task is run. */ … … 43 41 void before_thread_runs_arch(void) 44 42 { 45 supervisor_sp = (__address) &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA]; 46 supervisor_sp_physical = KA2PA(supervisor_sp_physical); 43 pht_init(); 44 tlb_invalidate_all(); 45 asm volatile ( 46 "mtsprg0 %0\n" 47 : 48 : "r" (KA2PA(&THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA])) 49 ); 47 50 } 48 51
Note:
See TracChangeset
for help on using the changeset viewer.