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.24 2006/07/11 04:44:09 debug Exp $ |
* $Id: dev_pccmos.c,v 1.28 2007/02/10 14:04:51 debug Exp $ |
29 |
* |
* |
30 |
* PC CMOS/RTC device (ISA ports 0x70 and 0x71). |
* PC CMOS/RTC device (ISA ports 0x70 and 0x71). |
31 |
* |
* |
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 = (struct pccmos_data *) extra; |
114 |
DEVINIT(pccmos) |
DEVINIT(pccmos) |
115 |
{ |
{ |
116 |
struct pccmos_data *d = malloc(sizeof(struct pccmos_data)); |
struct pccmos_data *d = malloc(sizeof(struct pccmos_data)); |
117 |
int irq_nr, type = MC146818_PC_CMOS, len = DEV_PCCMOS_LENGTH; |
int type = MC146818_PC_CMOS, len = DEV_PCCMOS_LENGTH; |
118 |
|
|
119 |
if (d == NULL) { |
if (d == NULL) { |
120 |
fprintf(stderr, "out of memory\n"); |
fprintf(stderr, "out of memory\n"); |
122 |
} |
} |
123 |
memset(d, 0, sizeof(struct pccmos_data)); |
memset(d, 0, sizeof(struct pccmos_data)); |
124 |
|
|
|
/* |
|
|
* Different machines use different IRQ schemes. |
|
|
*/ |
|
125 |
switch (devinit->machine->machine_type) { |
switch (devinit->machine->machine_type) { |
126 |
case MACHINE_CATS: |
case MACHINE_CATS: |
127 |
case MACHINE_NETWINDER: |
case MACHINE_NETWINDER: |
|
irq_nr = 32 + 8; |
|
128 |
type = MC146818_CATS; |
type = MC146818_CATS; |
129 |
d->ram[0x48] = 20; /* century */ |
d->ram[0x48] = 20; /* century */ |
130 |
len = DEV_PCCMOS_LENGTH * 2; |
len = DEV_PCCMOS_LENGTH * 2; |
131 |
break; |
break; |
132 |
case MACHINE_ALGOR: |
case MACHINE_ALGOR: |
|
irq_nr = 8 + 8; |
|
133 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
134 |
break; |
break; |
135 |
case MACHINE_ARC: |
case MACHINE_ARC: |
136 |
fatal("\nARC pccmos: TODO\n\n"); |
fatal("\nARC pccmos: TODO\n\n"); |
|
irq_nr = 8 + 8; /* TODO */ |
|
137 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
138 |
break; |
break; |
139 |
case MACHINE_EVBMIPS: |
case MACHINE_EVBMIPS: |
140 |
/* Malta etc. */ |
/* Malta etc. */ |
|
irq_nr = 8 + 8; |
|
141 |
type = MC146818_ALGOR; |
type = MC146818_ALGOR; |
142 |
break; |
break; |
143 |
case MACHINE_QEMU_MIPS: |
case MACHINE_QEMU_MIPS: |
144 |
irq_nr = 8 + 8; /* TODO. Bogus so far. */ |
case MACHINE_COBALT: |
|
break; |
|
|
case MACHINE_X86: |
|
|
irq_nr = 16; /* "No" irq */ |
|
|
break; |
|
145 |
case MACHINE_BEBOX: |
case MACHINE_BEBOX: |
146 |
case MACHINE_PREP: |
case MACHINE_PREP: |
147 |
case MACHINE_MVMEPPC: |
case MACHINE_MVMEPPC: |
|
irq_nr = 32 + 8; |
|
|
break; |
|
148 |
case MACHINE_SHARK: |
case MACHINE_SHARK: |
149 |
case MACHINE_IYONIX: |
case MACHINE_IYONIX: |
|
/* TODO */ |
|
|
irq_nr = 32 + 8; |
|
|
break; |
|
150 |
case MACHINE_ALPHA: |
case MACHINE_ALPHA: |
|
/* TODO */ |
|
|
irq_nr = 32 + 8; |
|
151 |
break; |
break; |
152 |
default:fatal("devinit_pccmos(): unimplemented machine type" |
default:fatal("devinit_pccmos(): unimplemented machine type" |
153 |
" %i\n", devinit->machine->machine_type); |
" %i\n", devinit->machine->machine_type); |
159 |
DM_DEFAULT, NULL); |
DM_DEFAULT, NULL); |
160 |
|
|
161 |
dev_mc146818_init(devinit->machine, devinit->machine->memory, |
dev_mc146818_init(devinit->machine, devinit->machine->memory, |
162 |
PCCMOS_MC146818_FAKE_ADDR, irq_nr, type, 1); |
PCCMOS_MC146818_FAKE_ADDR, devinit->interrupt_path, type, 1); |
163 |
|
|
164 |
return 1; |
return 1; |
165 |
} |
} |