Changeset 705 for trunk/softs
- Timestamp:
- May 28, 2014, 11:56:50 AM (10 years ago)
- Location:
- trunk/softs/tsar_boot/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/include/defs.h
r704 r705 8 8 #define BLOCK_SIZE 512 9 9 10 #ifndef CLUSTER_IO 11 # define CLUSTER_IO 0 12 #endif 13 10 14 // vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab 11 15 -
trunk/softs/tsar_boot/include/io.h
r704 r705 1 1 /********************************************************************** 2 * \file 3 * \date 4 * \author 2 * \file io.h 3 * \date 5 September 2012 4 * \author Cesar Fuguet / Alain Greiner 5 5 * 6 6 * Utility functions to write or read memory mapped hardware registers … … 26 26 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 27 27 : "=r" (value) 28 : "r" (addr), "r" (ext) ); 28 : "r" (addr), "r" (ext) 29 : "memory" ); 29 30 30 return value;31 return (volatile unsigned int)value; 31 32 } 32 33 … … 36 37 static inline unsigned short ioread16(void * addr) 37 38 { 38 return *(volatile unsigned short *) addr; 39 unsigned short value; 40 unsigned int ext = CLUSTER_IO; 41 42 asm volatile( 43 "mtc2 %2, $24 \n" /* PADDR_EXT <= cluster_io */ 44 "lhu %0, 0(%1) \n" /* value <= *(ext\addr) */ 45 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 46 : "=r" (value) 47 : "r" (addr), "r" (ext) 48 : "memory" ); 49 50 return (volatile unsigned short)value; 39 51 } 40 52 … … 44 56 static inline unsigned char ioread8(void * addr) 45 57 { 46 return *(volatile unsigned char *) addr; 58 unsigned char value; 59 unsigned int ext = CLUSTER_IO; 60 61 asm volatile( 62 "mtc2 %2, $24 \n" /* PADDR_EXT <= cluster_io */ 63 "lbu %0, 0(%1) \n" /* value <= *(ext\addr) */ 64 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 65 : "=r" (value) 66 : "r" (addr), "r" (ext) 67 : "memory" ); 68 69 return (volatile unsigned char)value; 47 70 } 48 71 … … 59 82 "sw %0, 0(%1) \n" /* *(ext\addr) <= value */ 60 83 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 61 84 "sync \n" /* sync barrier */ 62 85 : 63 : "r" (value), "r" (addr), "r" (ext) ); 86 : "r" (value), "r" (addr), "r" (ext) 87 : "memory" ); 64 88 } 65 89 … … 69 93 static inline void iowrite16(void * addr, unsigned short value) 70 94 { 71 *(volatile unsigned short *) addr = value; 72 asm volatile("sync" ::: "memory"); 95 unsigned int ext = CLUSTER_IO; 96 97 asm volatile( 98 "mtc2 %2, $24 \n" /* PADDR_EXT <= cluster_io */ 99 "sh %0, 0(%1) \n" /* *(ext\addr) <= value */ 100 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 101 "sync \n" /* sync barrier */ 102 : 103 : "r" (value), "r" (addr), "r" (ext) 104 : "memory" ); 73 105 } 74 106 … … 78 110 static inline void iowrite8(void * addr, unsigned char value) 79 111 { 80 *(volatile unsigned char *) addr = value; 81 asm volatile("sync" ::: "memory"); 112 unsigned int ext = CLUSTER_IO; 113 114 asm volatile( 115 "mtc2 %2, $24 \n" /* PADDR_EXT <= cluster_io */ 116 "sb %0, 0(%1) \n" /* *(ext\addr) <= value */ 117 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 118 "sync \n" /* sync barrier */ 119 : 120 : "r" (value), "r" (addr), "r" (ext) 121 : "memory" ); 82 122 } 83 123 84 124 #endif 125 126 // vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
Note: See TracChangeset
for help on using the changeset viewer.