1 |
/* |
/* |
2 |
* Copyright (C) 2005-2006 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_pccmos.c,v 1.22 2006/02/09 20:02:59 debug Exp $ |
* $Id: dev_pccmos.c,v 1.31 2007/06/15 19:57:33 debug Exp $ |
29 |
* |
* |
30 |
* PC CMOS/RTC device (ISA ports 0x70 and 0x71). |
* COMMENT: PC CMOS/RTC device (ISA ports 0x70 and 0x71) |
31 |
* |
* |
32 |
* The main point of this device is to be a "PC style wrapper" for accessing |
* The main point of this device is to be a "PC style wrapper" for accessing |
33 |
* the MC146818 (the RTC). In most other respects, this device is bogus, and |
* the MC146818 (the RTC). In most other respects, this device is bogus, and |
56 |
}; |
}; |
57 |
|
|
58 |
|
|
|
/* |
|
|
* dev_pccmos_access(): |
|
|
*/ |
|
59 |
DEVICE_ACCESS(pccmos) |
DEVICE_ACCESS(pccmos) |
60 |
{ |
{ |
61 |
struct pccmos_data *d = (struct pccmos_data *) extra; |
struct pccmos_data *d = extra; |
62 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
63 |
unsigned char b = 0; |
unsigned char b = 0; |
64 |
int r = 1; |
int r = 1; |
113 |
|
|
114 |
DEVINIT(pccmos) |
DEVINIT(pccmos) |
115 |
{ |
{ |
116 |
struct pccmos_data *d = malloc(sizeof(struct pccmos_data)); |
int type = MC146818_PC_CMOS, len = DEV_PCCMOS_LENGTH; |
117 |
int irq_nr, type = MC146818_PC_CMOS, len = DEV_PCCMOS_LENGTH; |
struct pccmos_data *d; |
118 |
|
|
119 |
if (d == NULL) { |
CHECK_ALLOCATION(d = malloc(sizeof(struct pccmos_data))); |
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
120 |
memset(d, 0, sizeof(struct pccmos_data)); |
memset(d, 0, sizeof(struct pccmos_data)); |
121 |
|
|
|
/* |
|
|
* Different machines use different IRQ schemes. |
|
|
*/ |
|
122 |
switch (devinit->machine->machine_type) { |
switch (devinit->machine->machine_type) { |
123 |
case MACHINE_CATS: |
case MACHINE_CATS: |
124 |
case MACHINE_NETWINDER: |
case MACHINE_NETWINDER: |
|
irq_nr = 32 + 8; |
|
125 |
type = MC146818_CATS; |
type = MC146818_CATS; |
126 |
d->ram[0x48] = 20; /* century */ |
d->ram[0x48] = 20; /* century */ |
127 |
len = DEV_PCCMOS_LENGTH * 2; |
len = DEV_PCCMOS_LENGTH * 2; |
128 |
break; |
break; |
129 |
case MACHINE_ALGOR: |
case MACHINE_ALGOR: |
|
irq_nr = 8 + 8; |
|
130 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
131 |
break; |
break; |
132 |
case MACHINE_ARC: |
case MACHINE_ARC: |
133 |
fatal("\nARC pccmos: TODO\n\n"); |
fatal("\nARC pccmos: TODO\n\n"); |
|
irq_nr = 8 + 8; /* TODO */ |
|
134 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
135 |
break; |
break; |
136 |
case MACHINE_EVBMIPS: |
case MACHINE_EVBMIPS: |
137 |
/* Malta etc. */ |
/* Malta etc. */ |
|
irq_nr = 8 + 8; |
|
138 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
139 |
break; |
break; |
140 |
case MACHINE_X86: |
case MACHINE_QEMU_MIPS: |
141 |
irq_nr = 16; /* "No" irq */ |
case MACHINE_COBALT: |
|
break; |
|
142 |
case MACHINE_BEBOX: |
case MACHINE_BEBOX: |
143 |
case MACHINE_PREP: |
case MACHINE_PREP: |
144 |
case MACHINE_MVMEPPC: |
case MACHINE_MVMEPPC: |
145 |
irq_nr = 32 + 8; |
case MACHINE_ALPHA: |
|
break; |
|
|
case MACHINE_SHARK: |
|
|
case MACHINE_IYONIX: |
|
|
/* TODO */ |
|
|
irq_nr = 32 + 8; |
|
146 |
break; |
break; |
147 |
default:fatal("devinit_pccmos(): unimplemented machine type" |
default:fatal("devinit_pccmos(): unimplemented machine type" |
148 |
" %i\n", devinit->machine->machine_type); |
" %i\n", devinit->machine->machine_type); |
154 |
DM_DEFAULT, NULL); |
DM_DEFAULT, NULL); |
155 |
|
|
156 |
dev_mc146818_init(devinit->machine, devinit->machine->memory, |
dev_mc146818_init(devinit->machine, devinit->machine->memory, |
157 |
PCCMOS_MC146818_FAKE_ADDR, irq_nr, type, 1); |
PCCMOS_MC146818_FAKE_ADDR, devinit->interrupt_path, type, 1); |
158 |
|
|
159 |
return 1; |
return 1; |
160 |
} |
} |