Revision 3cbee15b hw/ppc.c
b/hw/ppc.c | ||
---|---|---|
22 | 22 |
* THE SOFTWARE. |
23 | 23 |
*/ |
24 | 24 |
#include "vl.h" |
25 |
#include "m48t59.h" |
|
26 | 25 |
|
27 | 26 |
//#define PPC_DEBUG_IRQ |
28 | 27 |
//#define PPC_DEBUG_TB |
... | ... | |
1240 | 1239 |
|
1241 | 1240 |
/*****************************************************************************/ |
1242 | 1241 |
/* NVRAM helpers */ |
1243 |
void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value)
|
|
1242 |
static inline uint32_t nvram_read (nvram_t *nvram, uint32_t addr)
|
|
1244 | 1243 |
{ |
1245 |
m48t59_write(nvram, addr, value);
|
|
1244 |
return (*nvram->read_fn)(nvram->opaque, addr);;
|
|
1246 | 1245 |
} |
1247 | 1246 |
|
1248 |
uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr)
|
|
1247 |
static inline void nvram_write (nvram_t *nvram, uint32_t addr, uint32_t val)
|
|
1249 | 1248 |
{ |
1250 |
return m48t59_read(nvram, addr);
|
|
1249 |
(*nvram->write_fn)(nvram->opaque, addr, val);
|
|
1251 | 1250 |
} |
1252 | 1251 |
|
1253 |
void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value)
|
|
1252 |
void NVRAM_set_byte (nvram_t *nvram, uint32_t addr, uint8_t value)
|
|
1254 | 1253 |
{ |
1255 |
m48t59_write(nvram, addr, value >> 8); |
|
1256 |
m48t59_write(nvram, addr + 1, value & 0xFF); |
|
1254 |
nvram_write(nvram, addr, value); |
|
1257 | 1255 |
} |
1258 | 1256 |
|
1259 |
uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr) |
|
1257 |
uint8_t NVRAM_get_byte (nvram_t *nvram, uint32_t addr) |
|
1258 |
{ |
|
1259 |
return nvram_read(nvram, addr); |
|
1260 |
} |
|
1261 |
|
|
1262 |
void NVRAM_set_word (nvram_t *nvram, uint32_t addr, uint16_t value) |
|
1263 |
{ |
|
1264 |
nvram_write(nvram, addr, value >> 8); |
|
1265 |
nvram_write(nvram, addr + 1, value & 0xFF); |
|
1266 |
} |
|
1267 |
|
|
1268 |
uint16_t NVRAM_get_word (nvram_t *nvram, uint32_t addr) |
|
1260 | 1269 |
{ |
1261 | 1270 |
uint16_t tmp; |
1262 | 1271 |
|
1263 |
tmp = m48t59_read(nvram, addr) << 8; |
|
1264 |
tmp |= m48t59_read(nvram, addr + 1); |
|
1272 |
tmp = nvram_read(nvram, addr) << 8; |
|
1273 |
tmp |= nvram_read(nvram, addr + 1); |
|
1274 |
|
|
1265 | 1275 |
return tmp; |
1266 | 1276 |
} |
1267 | 1277 |
|
1268 |
void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value)
|
|
1278 |
void NVRAM_set_lword (nvram_t *nvram, uint32_t addr, uint32_t value)
|
|
1269 | 1279 |
{ |
1270 |
m48t59_write(nvram, addr, value >> 24);
|
|
1271 |
m48t59_write(nvram, addr + 1, (value >> 16) & 0xFF);
|
|
1272 |
m48t59_write(nvram, addr + 2, (value >> 8) & 0xFF);
|
|
1273 |
m48t59_write(nvram, addr + 3, value & 0xFF);
|
|
1280 |
nvram_write(nvram, addr, value >> 24);
|
|
1281 |
nvram_write(nvram, addr + 1, (value >> 16) & 0xFF);
|
|
1282 |
nvram_write(nvram, addr + 2, (value >> 8) & 0xFF);
|
|
1283 |
nvram_write(nvram, addr + 3, value & 0xFF);
|
|
1274 | 1284 |
} |
1275 | 1285 |
|
1276 |
uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr)
|
|
1286 |
uint32_t NVRAM_get_lword (nvram_t *nvram, uint32_t addr)
|
|
1277 | 1287 |
{ |
1278 | 1288 |
uint32_t tmp; |
1279 | 1289 |
|
1280 |
tmp = m48t59_read(nvram, addr) << 24;
|
|
1281 |
tmp |= m48t59_read(nvram, addr + 1) << 16;
|
|
1282 |
tmp |= m48t59_read(nvram, addr + 2) << 8;
|
|
1283 |
tmp |= m48t59_read(nvram, addr + 3);
|
|
1290 |
tmp = nvram_read(nvram, addr) << 24;
|
|
1291 |
tmp |= nvram_read(nvram, addr + 1) << 16;
|
|
1292 |
tmp |= nvram_read(nvram, addr + 2) << 8;
|
|
1293 |
tmp |= nvram_read(nvram, addr + 3);
|
|
1284 | 1294 |
|
1285 | 1295 |
return tmp; |
1286 | 1296 |
} |
1287 | 1297 |
|
1288 |
void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
|
|
1298 |
void NVRAM_set_string (nvram_t *nvram, uint32_t addr,
|
|
1289 | 1299 |
const unsigned char *str, uint32_t max) |
1290 | 1300 |
{ |
1291 | 1301 |
int i; |
1292 | 1302 |
|
1293 | 1303 |
for (i = 0; i < max && str[i] != '\0'; i++) { |
1294 |
m48t59_write(nvram, addr + i, str[i]);
|
|
1304 |
nvram_write(nvram, addr + i, str[i]);
|
|
1295 | 1305 |
} |
1296 |
m48t59_write(nvram, addr + max - 1, '\0'); |
|
1306 |
nvram_write(nvram, addr + i, str[i]); |
|
1307 |
nvram_write(nvram, addr + max - 1, '\0'); |
|
1297 | 1308 |
} |
1298 | 1309 |
|
1299 |
int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max)
|
|
1310 |
int NVRAM_get_string (nvram_t *nvram, uint8_t *dst, uint16_t addr, int max)
|
|
1300 | 1311 |
{ |
1301 | 1312 |
int i; |
1302 | 1313 |
|
... | ... | |
1325 | 1336 |
return tmp; |
1326 | 1337 |
} |
1327 | 1338 |
|
1328 |
uint16_t NVRAM_compute_crc (m48t59_t *nvram, uint32_t start, uint32_t count)
|
|
1339 |
uint16_t NVRAM_compute_crc (nvram_t *nvram, uint32_t start, uint32_t count)
|
|
1329 | 1340 |
{ |
1330 | 1341 |
uint32_t i; |
1331 | 1342 |
uint16_t crc = 0xFFFF; |
... | ... | |
1345 | 1356 |
|
1346 | 1357 |
#define CMDLINE_ADDR 0x017ff000 |
1347 | 1358 |
|
1348 |
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
|
|
1359 |
int PPC_NVRAM_set_params (nvram_t *nvram, uint16_t NVRAM_size,
|
|
1349 | 1360 |
const unsigned char *arch, |
1350 | 1361 |
uint32_t RAM_size, int boot_device, |
1351 | 1362 |
uint32_t kernel_image, uint32_t kernel_size, |
... | ... | |
1382 | 1393 |
NVRAM_set_word(nvram, 0x56, height); |
1383 | 1394 |
NVRAM_set_word(nvram, 0x58, depth); |
1384 | 1395 |
crc = NVRAM_compute_crc(nvram, 0x00, 0xF8); |
1385 |
NVRAM_set_word(nvram, 0xFC, crc); |
|
1396 |
NVRAM_set_word(nvram, 0xFC, crc);
|
|
1386 | 1397 |
|
1387 | 1398 |
return 0; |
1388 | 1399 |
} |
Also available in: Unified diff