1 |
/* |
/* |
2 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-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_sfb.c,v 1.6 2005/02/18 07:22:30 debug Exp $ |
* $Id: dev_sfb.c,v 1.11 2007/06/15 19:57:34 debug Exp $ |
29 |
* |
* |
30 |
* SFB TURBOchannel framebuffer. |
* COMMENT: SFB TURBOchannel framebuffer (graphics card) |
31 |
* |
* |
32 |
* See include/sfbreg.h (and NetBSD's arch/pmax/dev/sfb.c) for more info. |
* See include/sfbreg.h (and NetBSD's arch/pmax/dev/sfb.c) for more info. |
33 |
* |
* |
64 |
}; |
}; |
65 |
|
|
66 |
|
|
67 |
/* |
DEVICE_ACCESS(sfb) |
|
* dev_sfb_access(): |
|
|
*/ |
|
|
int dev_sfb_access(struct cpu *cpu, struct memory *mem, uint64_t relative_addr, |
|
|
unsigned char *data, size_t len, int writeflag, void *extra) |
|
68 |
{ |
{ |
69 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
70 |
struct sfb_data *d = extra; |
struct sfb_data *d = extra; |
71 |
|
|
72 |
idata = memory_readmax64(cpu, data, len); |
if (writeflag == MEM_WRITE) |
73 |
|
idata = memory_readmax64(cpu, data, len); |
74 |
|
|
75 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
76 |
odata = d->reg[(relative_addr >> 2) & (N_SFB_REGS - 1)]; |
odata = d->reg[(relative_addr >> 2) & (N_SFB_REGS - 1)]; |
97 |
{ |
{ |
98 |
struct sfb_data *d; |
struct sfb_data *d; |
99 |
|
|
100 |
d = malloc(sizeof(struct sfb_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct sfb_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
101 |
memset(d, 0, sizeof(struct sfb_data)); |
memset(d, 0, sizeof(struct sfb_data)); |
102 |
|
|
103 |
d->vfb_data = fb; |
d->vfb_data = fb; |
106 |
d->reg[(SFB_VVERTICAL - SFB_ASIC_OFFSET) / 4] = SFB_YSIZE; |
d->reg[(SFB_VVERTICAL - SFB_ASIC_OFFSET) / 4] = SFB_YSIZE; |
107 |
|
|
108 |
memory_device_register(mem, "sfb", baseaddr, SFB_REG_SIZE, |
memory_device_register(mem, "sfb", baseaddr, SFB_REG_SIZE, |
109 |
dev_sfb_access, d, MEM_DEFAULT, NULL); |
dev_sfb_access, d, DM_DEFAULT, NULL); |
110 |
} |
} |
111 |
|
|