1/* 2 * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#define FUNCTION(x) .global x; .type x,@function; x 7 8.text 9 10/* uint32 get_sdr1(void); 11 */ 12FUNCTION(get_sdr1): 13 mfsdr1 %r3 14 blr 15 16/* void set_sdr1(uint32 value); 17 * r3 18 */ 19FUNCTION(set_sdr1): 20 mtsdr1 %r3 21 blr 22 23/* uint32 get_sr(void *virtualAddress); 24 * r3 25 */ 26FUNCTION(get_sr): 27 mfsrin %r3, %r3 28 blr 29 30/* void set_sr(void *virtualAddress, uint32 value); 31 * r3 r4 32 */ 33FUNCTION(set_sr): 34 isync 35 mtsrin %r4, %r3 36 isync 37 blr 38 39/* uint32 get_msr(void); 40 */ 41FUNCTION(get_msr): 42 mfmsr %r3 43 blr 44 45/* uint32 set_msr(uint32 value); 46 * r3 47 */ 48FUNCTION(set_msr): 49 mtmsr %r3 50 isync 51 blr 52 53/* uint32 get_pvr(void); 54 */ 55FUNCTION(get_pvr): 56 mfpvr %r3 57 blr 58 59 60#define get_ibat(num) \ 61 mfibatu %r4, num; \ 62 stw %r4, 0(%r3); \ 63 mfibatl %r4, num; \ 64 stw %r4, 4(%r3); \ 65 66#define set_ibat(num); \ 67 lwz %r4, 0(%r3); \ 68 mtibatu num, %r4; \ 69 lwz %r4, 4(%r3); \ 70 mtibatl num, %r4; 71 72/* void get_ibat0-3(block_address_translation *bat); 73 * r3 74 */ 75FUNCTION(get_ibat0): 76 get_ibat(0) 77 blr 78FUNCTION(get_ibat1): 79 get_ibat(1) 80 blr 81FUNCTION(get_ibat2): 82 get_ibat(2) 83 blr 84FUNCTION(get_ibat3): 85 get_ibat(3) 86 blr 87 88/* void set_ibat0-3(block_address_translation *bat); 89 * r3 90 */ 91FUNCTION(set_ibat0): 92 set_ibat(0) 93 blr 94FUNCTION(set_ibat1): 95 set_ibat(1) 96 blr 97FUNCTION(set_ibat2): 98 set_ibat(2) 99 blr 100FUNCTION(set_ibat3): 101 set_ibat(3) 102 blr 103 104/* void reset_ibats(void) 105 */ 106FUNCTION(reset_ibats): 107 li %r3, 0 108 mtibatu 0, %r3 109 mtibatl 0, %r3 110 mtibatu 1, %r3 111 mtibatl 1, %r3 112 mtibatu 2, %r3 113 mtibatl 2, %r3 114 mtibatu 3, %r3 115 mtibatl 3, %r3 116 blr 117 118#define get_dbat(num) \ 119 mfdbatu %r4, num; \ 120 stw %r4, 0(%r3); \ 121 mfdbatl %r4, num; \ 122 stw %r4, 4(%r3); 123 124#define set_dbat(num) \ 125 lwz %r4, 0(%r3); \ 126 mtdbatu num, %r4; \ 127 lwz %r4, 4(%r3); \ 128 mtdbatl num, %r4; 129 130/* void get_dbat0-3(block_address_translation *bat); 131 * r3 132 */ 133FUNCTION(get_dbat0): 134 get_dbat(0) 135 blr 136FUNCTION(get_dbat1): 137 get_dbat(1) 138 blr 139FUNCTION(get_dbat2): 140 get_dbat(2) 141 blr 142FUNCTION(get_dbat3): 143 get_dbat(3) 144 blr 145 146/* void set_dbat0-3(block_address_translation *bat); 147 * r3 148 */ 149FUNCTION(set_dbat0): 150 set_dbat(0) 151 blr 152FUNCTION(set_dbat1): 153 set_dbat(1) 154 blr 155FUNCTION(set_dbat2): 156 set_dbat(2) 157 blr 158FUNCTION(set_dbat3): 159 set_dbat(3) 160 blr 161 162/* void reset_dbats(void) 163 */ 164FUNCTION(reset_dbats): 165 li %r3, 0 166 mtdbatu 0, %r3 167 mtdbatl 0, %r3 168 mtdbatu 1, %r3 169 mtdbatl 1, %r3 170 mtdbatu 2, %r3 171 mtdbatl 2, %r3 172 mtdbatu 3, %r3 173 mtdbatl 3, %r3 174 blr 175 176/* void __eieio(void) 177 */ 178FUNCTION(__eieio): 179 eieio 180 blr 181