forked from bcd/exec09
-
Notifications
You must be signed in to change notification settings - Fork 9
/
eon.c
116 lines (96 loc) · 2.96 KB
/
eon.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <fcntl.h>
#include "machine.h"
#include "eon.h"
#include "mmu.h"
#include "ioexpand.h"
#include "serial.h"
#include "imux.h"
#include "timer.h"
/**
* Initialize the EON machine.
*/
void eon_init (const char *boot_rom_file)
{
struct hw_device *dev, *ram_dev;
/* The MMU must be defined first, as all other devices
that are attached can try to hook into the MMU. */
device_define ( mmu_create (), 0,
MMU_ADDR, BUS_MAP_SIZE, MAP_READWRITE+MAP_FIXED );
/* A 1MB RAM part is mapped into all of the allowable 64KB
address space, until overriden by other devices. */
device_define ( ram_dev = ram_create (RAM_SIZE), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( rom_create (boot_rom_file, BOOT_ROM_SIZE), 0,
BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READABLE );
device_define ( dev = console_create (), 0,
CONSOLE_ADDR, BUS_MAP_SIZE, MAP_READWRITE );
device_define (dev, 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
device_define ( disk_create ("disk.bin", ram_dev), 0,
DISK_ADDR(0), BUS_MAP_SIZE, MAP_READWRITE);
}
/*
* Initialize the second-generation EON machine (EON2).
*/
void eon2_init (const char *boot_rom_file)
{
struct hw_device *dev, *ram_dev, *mmudev, *iodev, *intdev;
/* Create a 1MB RAM */
ram_dev = ram_create (0x100000);
/* Place the RAM behind a small MMU, which dynamically remaps
portions of the RAM into the processor address space */
mmudev = small_mmu_create (ram_dev);
/* Create and map in the ROM */
dev = rom_create (boot_rom_file, 0x800);
device_define (dev, 0, 0xF800, 0x0800, MAP_READABLE);
/* Create an I/O expander to hold all of the I/O registers.
Each device is allocated only 8 bytes. */
iodev = ioexpand_create ();
device_define (iodev, 0, 0xFF00, 128, MAP_READWRITE);
ioexpand_attach (iodev, 0, 0, serial_create ());
ioexpand_attach (iodev, 1, 0, disk_create ("disk.bin", ram_dev));
ioexpand_attach (iodev, 2, 0, mmudev);
ioexpand_attach (iodev, 3, 0, intdev = imux_create (1));
/* 4 = config EEPROM */
/* 5 = video display */
/* 6 = battery-backed clock */
/* 7 = power control (reboot/off) */
/* 8 = periodic timer/oscillator */
/* 9 = hostfile (for debug only) */
ioexpand_attach (iodev, 9, 0, hostfile_create ("hostfile", O_RDWR));
/* etc. up to device 15 */
/* May need to define an I/O _multiplexer_ to support more than 16 devices */
dev = oscillator_create (intdev, 0);
}
/**
* Initialize the simple machine, which is the default
* machine that has no bells or whistles.
*/
void simple_init (const char *boot_rom_file)
{
device_define ( ram_create (MAX_CPU_ADDR), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( console_create (), 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
}
struct machine eon_machine =
{
.name = "eon",
.fault = fault,
.init = eon_init,
.periodic = 0,
};
struct machine eon2_machine =
{
.name = "eon2",
.fault = fault,
.init = eon2_init,
.periodic = 0,
};
struct machine simple_machine =
{
.name = "simple",
.fault = fault,
.init = simple_init,
.periodic = 0,
};