1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_pmppc.c,v 1.5 2005/11/17 13:53:42 debug Exp $ |
* $Id: dev_pmppc.c,v 1.9 2007/06/15 19:57:33 debug Exp $ |
29 |
* |
* |
30 |
* PM/PPC devices. |
* COMMENT: Artesyn PM/PPC motherboard registers |
31 |
* |
* |
32 |
* TODO |
* NOTE/TODO: Only enough to boot NetBSD/pmppc has been implemented. |
33 |
*/ |
*/ |
34 |
|
|
35 |
#include <stdio.h> |
#include <stdio.h> |
37 |
#include <string.h> |
#include <string.h> |
38 |
|
|
39 |
#include "cpu.h" |
#include "cpu.h" |
40 |
#include "devices.h" |
#include "device.h" |
41 |
#include "machine.h" |
#include "machine.h" |
42 |
#include "memory.h" |
#include "memory.h" |
43 |
#include "misc.h" |
#include "misc.h" |
53 |
}; |
}; |
54 |
|
|
55 |
|
|
56 |
/* |
DEVICE_ACCESS(pmppc_board) |
|
* dev_pmppc_board_access(): |
|
|
*/ |
|
|
int dev_pmppc_board_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, int writeflag, |
|
|
void *extra) |
|
57 |
{ |
{ |
58 |
struct pmppc_data *d = extra; |
struct pmppc_data *d = extra; |
59 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
64 |
relative_addr += PMPPC_CONFIG0; |
relative_addr += PMPPC_CONFIG0; |
65 |
|
|
66 |
switch (relative_addr) { |
switch (relative_addr) { |
67 |
|
|
68 |
case PMPPC_CONFIG0: |
case PMPPC_CONFIG0: |
69 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
70 |
odata = d->config0; |
odata = d->config0; |
73 |
" 0x%02x ]\n", (int)idata); |
" 0x%02x ]\n", (int)idata); |
74 |
} |
} |
75 |
break; |
break; |
76 |
|
|
77 |
case PMPPC_CONFIG1: |
case PMPPC_CONFIG1: |
78 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
79 |
odata = d->config1; |
odata = d->config1; |
82 |
" 0x%02x ]\n", (int)idata); |
" 0x%02x ]\n", (int)idata); |
83 |
} |
} |
84 |
break; |
break; |
85 |
|
|
86 |
case PMPPC_RESET: |
case PMPPC_RESET: |
87 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
88 |
odata = d->reset_reg; |
odata = d->reset_reg; |
96 |
d->reset_reg = idata; |
d->reset_reg = idata; |
97 |
} |
} |
98 |
break; |
break; |
99 |
|
|
100 |
default: |
default: |
101 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
102 |
debug("[ pmppc: UNIMPLEMENTED read from 0x%08lx ]\n", |
debug("[ pmppc: UNIMPLEMENTED read from 0x%08lx ]\n", |
114 |
} |
} |
115 |
|
|
116 |
|
|
117 |
/* |
DEVINIT(pmppc) |
|
* dev_pmppc_init(): |
|
|
*/ |
|
|
void dev_pmppc_init(struct memory *mem) |
|
118 |
{ |
{ |
119 |
struct pmppc_data *d; |
struct pmppc_data *d; |
120 |
|
struct memory *mem = devinit->machine->memory; |
121 |
|
|
122 |
d = malloc(sizeof(struct pmppc_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct pmppc_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
123 |
memset(d, 0, sizeof(struct pmppc_data)); |
memset(d, 0, sizeof(struct pmppc_data)); |
124 |
|
|
125 |
/* |
/* |
159 |
|
|
160 |
memory_device_register(mem, "pmppc_board", |
memory_device_register(mem, "pmppc_board", |
161 |
PMPPC_CONFIG0, 0x10, dev_pmppc_board_access, d, DM_DEFAULT, NULL); |
PMPPC_CONFIG0, 0x10, dev_pmppc_board_access, d, DM_DEFAULT, NULL); |
162 |
|
|
163 |
|
return 1; |
164 |
} |
} |
165 |
|
|