Skip to content

Commit bbe2c8a

Browse files
committed
Copy reset stack and program counter from ROM to RAM
Copy the reset supervisor stack pointer and reset program counter from ROM to RAM to emulate the ROM overlay during processor reset.
1 parent e22d0d6 commit bbe2c8a

File tree

6 files changed

+9
-21
lines changed

6 files changed

+9
-21
lines changed

include/atari/rom.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "atari/device.h"
1010

11-
extern const struct device rom0_device;
12-
extern const struct device rom1_device;
11+
extern const struct device rom_device;
1312

1413
#endif /* ATARI_ROM_H */

lib/atari/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
lib/atari/rom.c: $(LIBPSGPLAY_TOS_HEADER)
3+
lib/atari/ram.c lib/atari/rom.c: $(LIBPSGPLAY_TOS_HEADER)
44

55
ATARI_SRC := $(addprefix lib/atari/, \
66
bus.c \

lib/atari/device.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ static struct machine_device {
2525
u64 machine_cycle_event;
2626
const struct device *device;
2727
} list[] = {
28-
{ .device = &rom0_device },
29-
{ .device = &rom1_device },
28+
{ .device = &rom_device },
3029
{ .device = &glue_device },
3130
{ .device = &ram_device },
3231
{ .device = &mfp_device },

lib/atari/mmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ static void mmu_bus_wait(const struct device *dev)
3838
valid_device_bus_address(bus_address, dev) ? dev
3939
#define DMA_DEVICES(bus_address) \
4040
DMA_DEVICE(bus_address, &ram_device) : \
41-
DMA_DEVICE(bus_address, &rom0_device) : \
42-
DMA_DEVICE(bus_address, &rom1_device) : NULL
41+
DMA_DEVICE(bus_address, &rom_device) : NULL
4342

4443
u8 dma_read_memory_8(u32 bus_address)
4544
{

lib/atari/ram.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
#include "atari/sound.h"
1313
#include "atari/system-variable.h"
1414

15+
#include "tos/tos.h"
16+
1517
static u8 ram[4 * 1024 * 1024]; /* 4 MiB of RAM */
1618

1719
static void ram_reset(const struct device *device)
1820
{
19-
memset(ram, 0, sizeof(ram));
21+
memcpy(&ram[0], tos, 8); /* ROM overlay during reset */
22+
memset(&ram[8], 0, sizeof(ram) - 8);
2023
}
2124

2225
static u8 ram_rd_u8(const struct device *device, u32 dev_address)

lib/atari/rom.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,7 @@ static u16 rom_rd_u16(const struct device *device, u32 dev_address)
2020
(tos[dev_address] << 8) | tos[dev_address + 1] : 0;
2121
}
2222

23-
const struct device rom0_device = {
24-
.name = "rom",
25-
.bus = {
26-
.address = 0,
27-
.size = 8,
28-
},
29-
.rd_u8 = rom_rd_u8,
30-
.rd_u16 = rom_rd_u16,
31-
.wr_u8 = bus_error_wr_u8,
32-
.wr_u16 = bus_error_wr_u16,
33-
};
34-
35-
const struct device rom1_device = {
23+
const struct device rom_device = {
3624
.name = "rom",
3725
.frequency = 8000000,
3826
.bus = {

0 commit comments

Comments
 (0)