Changeset 1df1905 in mainline for uspace/lib/c/arch/sparc32/include
- Timestamp:
- 2013-12-28T17:30:44Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41b735f3
- Parents:
- c1023bcb
- Location:
- uspace/lib/c/arch/sparc32/include/libarch
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/sparc32/include/libarch/atomic.h
rc1023bcb r1df1905 27 27 */ 28 28 29 /** @addtogroup libcsparc 6429 /** @addtogroup libcsparc32 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_sparc 64_ATOMIC_H_36 #define LIBC_sparc 64_ATOMIC_H_35 #ifndef LIBC_sparc32_ATOMIC_H_ 36 #define LIBC_sparc32_ATOMIC_H_ 37 37 38 38 #define LIBC_ARCH_ATOMIC_H_ 39 39 40 #define CAS40 #define CAS 41 41 42 42 #include <atomicdflt.h> … … 53 53 } 54 54 55 static inline void atomic_inc(atomic_t *val) { 56 /* On real hardware the increment has to be done 57 as an atomic action. */ 58 55 static inline void atomic_inc(atomic_t *val) 56 { 57 // FIXME TODO 59 58 val->count++; 60 59 } 61 60 62 static inline void atomic_dec(atomic_t *val) { 63 /* On real hardware the decrement has to be done 64 as an atomic action. */ 65 61 static inline void atomic_dec(atomic_t *val) 62 { 63 // FIXME TODO 66 64 val->count++; 67 65 } … … 69 67 static inline atomic_count_t atomic_postinc(atomic_t *val) 70 68 { 71 /* On real hardware both the storing of the previous 72 value and the increment have to be done as a single 73 atomic action. */ 69 // FIXME TODO 74 70 75 71 atomic_count_t prev = val->count; … … 81 77 static inline atomic_count_t atomic_postdec(atomic_t *val) 82 78 { 83 /* On real hardware both the storing of the previous 84 value and the decrement have to be done as a single 85 atomic action. */ 79 // FIXME TODO 86 80 87 81 atomic_count_t prev = val->count; … … 94 88 #define atomic_predec(val) (atomic_postdec(val) - 1) 95 89 96 #if 097 /** Atomic add operation.98 *99 * Use atomic compare and swap operation to atomically add signed value.100 *101 * @param val Atomic variable.102 * @param i Signed value to be added.103 *104 * @return Value of the atomic variable as it existed before addition.105 *106 */107 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)108 {109 atomic_count_t a;110 atomic_count_t b;111 112 do {113 volatile uintptr_t ptr = (uintptr_t) &val->count;114 115 a = *((atomic_count_t *) ptr);116 b = a + i;117 118 // XXX asm volatile (119 // "cas %0, %2, %1\n"120 // : "+m" (*((atomic_count_t *) ptr)),121 // "+r" (b)122 // : "r" (a)123 // );124 } while (a != b);125 126 return a;127 }128 129 static inline atomic_count_t atomic_preinc(atomic_t *val)130 {131 return atomic_add(val, 1) + 1;132 }133 134 static inline atomic_count_t atomic_postinc(atomic_t *val)135 {136 return atomic_add(val, 1);137 }138 139 static inline atomic_count_t atomic_predec(atomic_t *val)140 {141 return atomic_add(val, -1) - 1;142 }143 144 static inline atomic_count_t atomic_postdec(atomic_t *val)145 {146 return atomic_add(val, -1);147 }148 149 static inline void atomic_inc(atomic_t *val)150 {151 (void) atomic_add(val, 1);152 }153 154 static inline void atomic_dec(atomic_t *val)155 {156 (void) atomic_add(val, -1);157 }158 #endif159 160 90 #endif 161 91 -
uspace/lib/c/arch/sparc32/include/libarch/config.h
rc1023bcb r1df1905 36 36 #define LIBC_sparc32_CONFIG_H_ 37 37 38 #define PAGE_WIDTH 1239 #define PAGE_SIZE (1 << PAGE_WIDTH)38 #define PAGE_WIDTH 12 39 #define PAGE_SIZE (1 << PAGE_WIDTH) 40 40 41 41 #endif -
uspace/lib/c/arch/sparc32/include/libarch/ddi.h
rc1023bcb r1df1905 1 1 /* 2 * Copyright (c) 2009 Jakub Jermar 2 * Copyright (c) 2009 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @file 30 * @ingroup libsparc 6430 * @ingroup libsparc32 31 31 */ 32 32 33 #ifndef LIBC_sparc 64_DDI_H_34 #define LIBC_sparc 64_DDI_H_33 #ifndef LIBC_sparc32_DDI_H_ 34 #define LIBC_sparc32_DDI_H_ 35 35 36 36 #include <sys/types.h> … … 65 65 static inline uint8_t arch_pio_read_8(const ioport8_t *port) 66 66 { 67 uint8_t rv; 68 69 rv = *port; 67 uint8_t rv = *port; 70 68 memory_barrier(); 71 69 72 70 return rv; 73 71 } … … 75 73 static inline uint16_t arch_pio_read_16(const ioport16_t *port) 76 74 { 77 uint16_t rv; 78 79 rv = *port; 75 uint16_t rv = *port; 80 76 memory_barrier(); 81 77 82 78 return rv; 83 79 } … … 85 81 static inline uint32_t arch_pio_read_32(const ioport32_t *port) 86 82 { 87 uint32_t rv; 88 89 rv = *port; 83 uint32_t rv = *port; 90 84 memory_barrier(); 91 85 92 86 return rv; 93 87 } -
uspace/lib/c/arch/sparc32/include/libarch/elf_linux.h
rc1023bcb r1df1905 27 27 */ 28 28 29 /** @addtogroup libcsparc 6429 /** @addtogroup libcsparc32 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_sparc 64_ELF_LINUX_H_36 #define LBIC_sparc 64_ELF_LINUX_H_35 #ifndef LIBC_sparc32_ELF_LINUX_H_ 36 #define LBIC_sparc32_ELF_LINUX_H_ 37 37 38 38 #include <libarch/istate.h> … … 47 47 { 48 48 /* TODO */ 49 (void) istate; (void) elf_regs; 49 (void) istate; 50 (void) elf_regs; 50 51 } 51 52 -
uspace/lib/c/arch/sparc32/include/libarch/faddr.h
rc1023bcb r1df1905 27 27 */ 28 28 29 /** @addtogroup libcsparc 6429 /** @addtogroup libcsparc32 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_sparc 64_FADDR_H_36 #define LIBC_sparc 64_FADDR_H_35 #ifndef LIBC_sparc32_FADDR_H_ 36 #define LIBC_sparc32_FADDR_H_ 37 37 38 38 #include <libarch/types.h> 39 39 40 #define FADDR(fptr) ((uintptr_t) (fptr))40 #define FADDR(fptr) ((uintptr_t) (fptr)) 41 41 42 42 #endif -
uspace/lib/c/arch/sparc32/include/libarch/fibril.h
rc1023bcb r1df1905 56 56 */ 57 57 typedef struct { 58 uintptr_t sp; /* %o6 */59 uintptr_t pc; /* %o7 */58 uintptr_t sp; /* %o6 */ 59 uintptr_t pc; /* %o7 */ 60 60 uint32_t i0; 61 61 uint32_t i1; … … 64 64 uint32_t i4; 65 65 uint32_t i5; 66 uintptr_t fp; /* %i6 */66 uintptr_t fp; /* %i6 */ 67 67 uintptr_t i7; 68 68 uint32_t l0; … … 74 74 uint32_t l6; 75 75 uint32_t l7; 76 uint32_t tp; /* %g7 */76 uint32_t tp; /* %g7 */ 77 77 } context_t; 78 78 -
uspace/lib/c/arch/sparc32/include/libarch/stack.h
rc1023bcb r1df1905 27 27 */ 28 28 29 /** @addtogroup libcsparc 6429 /** @addtogroup libcsparc32 30 30 * @{ 31 31 */ … … 36 36 #define LIBC_sparc32_STACK_H_ 37 37 38 #define STACK_ITEM_SIZE 438 #define STACK_ITEM_SIZE 4 39 39 40 /** According to SPARC Compliance Definition, every stack frame is 16-byte aligned. */ 41 #define STACK_ALIGNMENT 8 40 #define STACK_ALIGNMENT 8 42 41 43 /** 44 * 16-extended-word save area for %i[0-7] and %l[0-7] registers. 45 */ 46 #define STACK_WINDOW_SAVE_AREA_SIZE (16 * STACK_ITEM_SIZE) 42 /** 16-extended-word save area for %i[0-7] and %l[0-7] registers. */ 43 #define STACK_WINDOW_SAVE_AREA_SIZE (16 * STACK_ITEM_SIZE) 47 44 48 /* 49 * Six extended words for first six arguments. 50 */ 51 #define STACK_ARG_SAVE_AREA_SIZE (6 * STACK_ITEM_SIZE) 45 /* Six extended words for first six arguments. */ 46 #define STACK_ARG_SAVE_AREA_SIZE (6 * STACK_ITEM_SIZE) 52 47 53 48 #endif -
uspace/lib/c/arch/sparc32/include/libarch/syscall.h
rc1023bcb r1df1905 39 39 #include <abi/syscall.h> 40 40 41 #define __syscall0 __syscall42 #define __syscall1 __syscall43 #define __syscall2 __syscall44 #define __syscall3 __syscall45 #define __syscall4 __syscall46 #define __syscall5 __syscall47 #define __syscall6 __syscall41 #define __syscall0 __syscall 42 #define __syscall1 __syscall 43 #define __syscall2 __syscall 44 #define __syscall3 __syscall 45 #define __syscall4 __syscall 46 #define __syscall5 __syscall 47 #define __syscall6 __syscall 48 48 49 static inline sysarg_t 50 __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3,51 const sys arg_t p4, const sysarg_t p5, const sysarg_t p6, const syscall_t id)49 static inline sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, 50 const sysarg_t p3, const sysarg_t p4, const sysarg_t p5, const sysarg_t p6, 51 const syscall_t id) 52 52 { 53 53 register uint32_t a1 asm("o0") = p1; … … 57 57 register uint32_t a5 asm("o4") = p5; 58 58 register uint32_t a6 asm("o5") = p6; 59 59 60 60 asm volatile ( 61 61 "ta %7\n" 62 62 : "=r" (a1) 63 : "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), 63 : "r" (a1), 64 "r" (a2), 65 "r" (a3), 66 "r" (a4), 67 "r" (a5), 68 "r" (a6), 64 69 "i" (id) 65 70 : "memory" -
uspace/lib/c/arch/sparc32/include/libarch/tls.h
rc1023bcb r1df1905 28 28 */ 29 29 30 /** @addtogroup libcsparc 6430 /** @addtogroup libcsparc32 31 31 * @{ 32 32 */ 33 /** 34 * @file 35 * @brief sparc64 TLS functions. 33 /** @file 34 * @brief sparc32 TLS functions. 36 35 */ 37 36 38 #ifndef LIBC_sparc 64_TLS_H_39 #define LIBC_sparc 64_TLS_H_37 #ifndef LIBC_sparc32_TLS_H_ 38 #define LIBC_sparc32_TLS_H_ 40 39 41 40 #define CONFIG_TLS_VARIANT_2 … … 48 47 static inline void __tcb_set(tcb_t *tcb) 49 48 { 50 asm volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7"); 49 asm volatile( 50 "mov %0, %%g7\n" 51 :: "r" (tcb) 52 : "g7" 53 ); 51 54 } 52 55 53 static inline tcb_t * __tcb_get(void)56 static inline tcb_t *__tcb_get(void) 54 57 { 55 58 void *retval; 56 57 asm volatile ("mov %%g7, %0\n" : "=r" (retval)); 58 59 60 asm volatile( 61 "mov %%g7, %0\n" 62 : "=r" (retval) 63 ); 64 59 65 return retval; 60 66 }
Note:
See TracChangeset
for help on using the changeset viewer.
