dev_prep.cc Source File

Back to the index.

dev_prep.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-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: PReP machine mainbus (ISA bus + interrupt controller)
29  */
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "bus_isa.h"
36 #include "cpu.h"
37 #include "device.h"
38 #include "machine.h"
39 #include "memory.h"
40 #include "misc.h"
41 
42 
43 struct prep_data {
44  uint32_t int_status;
45 };
46 
47 
49 {
50  /* struct prep_data *d = extra; */
51  uint64_t idata = 0, odata = 0;
52 
53  if (writeflag == MEM_WRITE)
54  idata = memory_readmax64(cpu, data, len);
55 
56  if (writeflag == MEM_READ) {
57  odata = cpu->machine->isa_pic_data.last_int;
58  } else {
59  fatal("[ prep: write to interrupt register? ]\n");
60  }
61 
62  if (writeflag == MEM_READ)
63  memory_writemax64(cpu, data, len, odata);
64 
65  return 1;
66 }
67 
68 
69 DEVINIT(prep)
70 {
71  struct prep_data *d;
72 
73  CHECK_ALLOCATION(d = (struct prep_data *) malloc(sizeof(struct prep_data)));
74  memset(d, 0, sizeof(struct prep_data));
75 
77  0xbffff000, 0x1000, dev_prep_access, d, DM_DEFAULT, NULL);
78 
79  /* This works for at least the IBM 6050: */
81  BUS_ISA_IDE0 | BUS_ISA_IDE1, 0x80000000, 0xc0000000);
82 
83  return 1;
84 }
85 
data
u_short data
Definition: siireg.h:79
prep_data::int_status
uint32_t int_status
Definition: dev_prep.cc:44
bus_isa.h
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
MEM_READ
#define MEM_READ
Definition: memory.h:116
DM_DEFAULT
#define DM_DEFAULT
Definition: memory.h:130
devinit::machine
struct machine * machine
Definition: device.h:41
isa_pic_data::last_int
int last_int
Definition: machine.h:52
device.h
BUS_ISA_IDE0
#define BUS_ISA_IDE0
Definition: bus_isa.h:58
MEM_WRITE
#define MEM_WRITE
Definition: memory.h:117
BUS_ISA_IDE1
#define BUS_ISA_IDE1
Definition: bus_isa.h:59
devinit::interrupt_path
char * interrupt_path
Definition: device.h:50
fatal
void fatal(const char *fmt,...)
Definition: main.cc:152
machine::isa_pic_data
struct isa_pic_data isa_pic_data
Definition: machine.h:190
misc.h
memory_readmax64
uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len)
Definition: memory.cc:55
machine.h
devinit::name
char * name
Definition: device.h:43
devinit
Definition: device.h:40
cpu.h
machine::memory
struct memory * memory
Definition: machine.h:126
bus_isa_init
struct bus_isa_data * bus_isa_init(struct machine *machine, char *interrupt_base_path, uint32_t bus_isa_flags, uint64_t isa_portbase, uint64_t isa_membase)
Definition: bus_isa.cc:174
cpu::machine
struct machine * machine
Definition: cpu.h:328
prep_data
Definition: dev_prep.cc:43
memory_writemax64
void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len, uint64_t data)
Definition: memory.cc:89
DEVICE_ACCESS
DEVICE_ACCESS(prep)
Definition: dev_prep.cc:48
DEVINIT
DEVINIT(prep)
Definition: dev_prep.cc:69
cpu
Definition: cpu.h:326
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