ROM partially overlaid with RAM?

Discussion of development and patch submission.
Post Reply
User avatar
JohnElliott
Posts: 113
Joined: Sun 31 Jan, 2016 7:29 pm

ROM partially overlaid with RAM?

Post by JohnElliott »

I'm experimenting with implementing a video card which has an 8k BIOS ROM at 0xC0000, as expected. But it also has the ability to page in 2k of RAM over the last 2k of ROM (ie, at 0xC1800).

My question is, what's the best way to implement this in PCEM? I've tried using rom_init() to load the ROM, and mem_mapping_add() to create the RAM mapping:

Code: Select all

	rom_init(&sigma->bios_rom, "sigma400_bios.rom", 0xC0000, 0x2000, 0x1FFF, 0, MEM_MAPPING_EXTERNAL);
        mem_mapping_add(&sigma->bios_ram, 0xC1800, 0x0800, sigma_bread, NULL, NULL, sigma_bwrite, NULL, NULL,  NULL, MEM_MAPPING_EXTERNAL, sigma);
but memory reads outside the 0xC1800-0xC2000 range end up being handled by the sigma_bread / sigma_bwrite handlers, and even if I forward them to the ROM the processor ends up in a tight loop with 'Bad getpccache' errors in the log.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: ROM partially overlaid with RAM?

Post by SarahWalker »

PCem memory mapping has a 16kb granularity, so as you've discovered mapping less than that is non trivial. You're mostly there though - have sigma_bread/write forward accesses in C0000-C17FF to ROM, and pass a pointer to the ROM to the exec parameter of mem_mapping_add() to fix the getpccache issues. Have a look at scsi_53c400.c - that does something similar to what you want.
User avatar
JohnElliott
Posts: 113
Joined: Sun 31 Jan, 2016 7:29 pm

Re: ROM partially overlaid with RAM?

Post by JohnElliott »

Thanks! That's got the ROM paging working - now I just need to implement everything else...
Post Reply