dev_sfb.cc Source File

Back to the index.

dev_sfb.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2009 Anders Gavare. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  *
28  * COMMENT: SFB TURBOchannel framebuffer (graphics card)
29  *
30  * See include/sfbreg.h (and NetBSD's arch/pmax/dev/sfb.c) for more info.
31  *
32  *
33  * TODO: This is not really implemented yet. It "happens" to work with
34  * NetBSD and OpenBSD, but not with Ultrix yet.
35  */
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 
41 #include "devices.h"
42 #include "memory.h"
43 #include "misc.h"
44 
45 #include "thirdparty/sfbreg.h"
46 
47 
48 #define SFB_XSIZE 1280
49 #define SFB_YSIZE 1024
50 
51 
52 /* #define debug fatal */
53 
54 
55 #define SFB_REG_SIZE 0x80
56 #define N_SFB_REGS (SFB_REG_SIZE / 4)
57 
58 
59 struct sfb_data {
60  struct vfb_data *vfb_data;
61 
62  uint32_t reg[N_SFB_REGS];
63 };
64 
65 
67 {
68  uint64_t idata = 0, odata = 0;
69  struct sfb_data *d = (struct sfb_data *) extra;
70 
71  if (writeflag == MEM_WRITE)
72  idata = memory_readmax64(cpu, data, len);
73 
74  if (writeflag==MEM_READ) {
75  odata = d->reg[(relative_addr >> 2) & (N_SFB_REGS - 1)];
76  debug("[ sfb: read from addr 0x%x: 0x%llx ]\n",
77  (int)relative_addr, (long long)odata);
78  } else {
79  d->reg[(relative_addr >> 2) & (N_SFB_REGS - 1)] = idata;
80  debug("[ sfb: write to addr 0x%x: 0x%llx ]\n",
81  (int)relative_addr, (long long)idata);
82  }
83 
84  if (writeflag == MEM_READ)
85  memory_writemax64(cpu, data, len, odata);
86 
87  return 1;
88 }
89 
90 
91 /*
92  * dev_sfb_init():
93  */
94 void dev_sfb_init(struct machine *machine, struct memory *mem,
95  uint64_t baseaddr, struct vfb_data *fb)
96 {
97  struct sfb_data *d;
98 
99  CHECK_ALLOCATION(d = (struct sfb_data *) malloc(sizeof(struct sfb_data)));
100  memset(d, 0, sizeof(struct sfb_data));
101 
102  d->vfb_data = fb;
103 
104  d->reg[(SFB_VHORIZONTAL - SFB_ASIC_OFFSET) / 4] = SFB_XSIZE >> 2;
106 
107  memory_device_register(mem, "sfb", baseaddr, SFB_REG_SIZE,
108  dev_sfb_access, d, DM_DEFAULT, NULL);
109 }
110 
data
u_short data
Definition: siireg.h:79
SFB_VVERTICAL
#define SFB_VVERTICAL
Definition: sfbreg.h:71
memory
Definition: memory.h:75
debug
#define debug
Definition: dev_adb.cc:57
sfb_data::vfb_data
struct vfb_data * vfb_data
Definition: dev_sfb.cc:60
memory_device_register
void memory_device_register(struct memory *mem, const char *, uint64_t baseaddr, uint64_t len, int(*f)(struct cpu *, struct memory *, uint64_t, unsigned char *, size_t, int, void *), void *extra, int flags, unsigned char *dyntrans_data)
Definition: memory.cc:339
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 *)
N_SFB_REGS
#define N_SFB_REGS
Definition: dev_sfb.cc:56
MEM_READ
#define MEM_READ
Definition: memory.h:116
DM_DEFAULT
#define DM_DEFAULT
Definition: memory.h:130
DEVICE_ACCESS
DEVICE_ACCESS(sfb)
Definition: dev_sfb.cc:66
SFB_ASIC_OFFSET
#define SFB_ASIC_OFFSET
Definition: sfbreg.h:45
MEM_WRITE
#define MEM_WRITE
Definition: memory.h:117
SFB_XSIZE
#define SFB_XSIZE
Definition: dev_sfb.cc:48
SFB_VHORIZONTAL
#define SFB_VHORIZONTAL
Definition: sfbreg.h:70
sfbreg.h
misc.h
memory_readmax64
uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len)
Definition: memory.cc:55
machine
Definition: machine.h:97
SFB_YSIZE
#define SFB_YSIZE
Definition: dev_sfb.cc:49
sfb_data::reg
uint32_t reg[N_SFB_REGS]
Definition: dev_sfb.cc:62
dev_sfb_init
void dev_sfb_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, struct vfb_data *fb)
Definition: dev_sfb.cc:94
memory_writemax64
void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len, uint64_t data)
Definition: memory.cc:89
devices.h
cpu
Definition: cpu.h:326
SFB_REG_SIZE
#define SFB_REG_SIZE
Definition: dev_sfb.cc:55
sfb_data
Definition: dev_sfb.cc:59
vfb_data
Definition: devices.h:198
memory.h
CHECK_ALLOCATION
#define CHECK_ALLOCATION(ptr)
Definition: misc.h:239

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18