1 |
/* |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-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_kn01.c,v 1.8 2006/01/01 13:17:16 debug Exp $ |
* $Id: dev_kn01.c,v 1.10 2007/01/05 15:20:06 debug Exp $ |
29 |
* |
* |
30 |
* KN01 stuff ("PMAX", DECstation type 1); CSR (System Control Register) |
* KN01 stuff ("PMAX", DECstation type 1); CSR (System Control Register) |
31 |
* and VDAC. |
* and VDAC. |
49 |
#include "dec_kn01.h" |
#include "dec_kn01.h" |
50 |
|
|
51 |
|
|
52 |
struct kn01_csr_data { |
struct kn01_data { |
53 |
int color_fb; |
int color_fb; |
54 |
int csr; |
uint32_t csr; |
55 |
}; |
}; |
56 |
|
|
57 |
|
|
78 |
}; |
}; |
79 |
|
|
80 |
|
|
81 |
/* |
DEVICE_ACCESS(kn01) |
|
* dev_kn01_csr_access(): |
|
|
*/ |
|
|
DEVICE_ACCESS(kn01_csr) |
|
82 |
{ |
{ |
83 |
struct kn01_csr_data *k = extra; |
struct kn01_data *d = extra; |
84 |
int csr; |
int csr; |
85 |
|
|
86 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
90 |
|
|
91 |
/* Read: */ |
/* Read: */ |
92 |
if (len != 2 || relative_addr != 0) { |
if (len != 2 || relative_addr != 0) { |
93 |
fatal("[ kn01_csr: trying to read something which is not " |
fatal("[ kn01: trying to read something which is not " |
94 |
"the first half-word of the csr ]"); |
"the first half-word of the csr ]"); |
95 |
} |
} |
96 |
|
|
97 |
csr = k->csr; |
csr = d->csr; |
98 |
|
|
99 |
if (cpu->byte_order == EMUL_LITTLE_ENDIAN) { |
if (cpu->byte_order == EMUL_LITTLE_ENDIAN) { |
100 |
data[0] = csr & 0xff; |
data[0] = csr & 0xff; |
251 |
|
|
252 |
|
|
253 |
/* |
/* |
254 |
* dev_kn01_csr_init(): |
* dev_kn01_init(): |
255 |
*/ |
*/ |
256 |
void dev_kn01_csr_init(struct memory *mem, uint64_t baseaddr, int color_fb) |
void dev_kn01_init(struct memory *mem, uint64_t baseaddr, int color_fb) |
257 |
{ |
{ |
258 |
struct kn01_csr_data *k = malloc(sizeof(struct kn01_csr_data)); |
struct kn01_data *d = malloc(sizeof(struct kn01_data)); |
259 |
if (k == NULL) { |
if (d == NULL) { |
260 |
fprintf(stderr, "out of memory\n"); |
fprintf(stderr, "out of memory\n"); |
261 |
exit(1); |
exit(1); |
262 |
} |
} |
263 |
|
|
264 |
memset(k, 0, sizeof(struct kn01_csr_data)); |
memset(d, 0, sizeof(struct kn01_data)); |
265 |
k->color_fb = color_fb; |
d->color_fb = color_fb; |
266 |
|
|
267 |
k->csr = 0; |
d->csr = 0; |
268 |
k->csr |= (color_fb? 0 : KN01_CSR_MONO); |
d->csr |= (color_fb? 0 : KN01_CSR_MONO); |
269 |
|
|
270 |
memory_device_register(mem, "kn01_csr", baseaddr, |
memory_device_register(mem, "kn01", baseaddr, |
271 |
DEV_KN01_CSR_LENGTH, dev_kn01_csr_access, k, DM_DEFAULT, NULL); |
DEV_KN01_LENGTH, dev_kn01_access, d, DM_DEFAULT, NULL); |
272 |
} |
} |
273 |
|
|