Added the Catalyst 28F010 Flash chip needed by the ASUS P5MP3, fixed a memory leak in the Intel Flash close code (it was not free'ing dev->array), and unified all the flash chip header files into one single flash.h.
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of an SST flash chip.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Author: Melissa Goad, <mszoopers@protonmail.com>
|
||||
* Copyright 2020 Melissa Goad.
|
||||
*/
|
||||
|
||||
extern const device_t sst_flash_29ee010_device;
|
||||
extern const device_t sst_flash_29ee020_device;
|
||||
extern const device_t sst_flash_39sf010_device;
|
||||
extern const device_t sst_flash_39sf020_device;
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Handling of the emulated flash devices.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2020 Miran Grca.
|
||||
*/
|
||||
|
||||
extern const device_t catalyst_flash_device;
|
||||
|
||||
extern const device_t intel_flash_bxt_ami_device;
|
||||
extern const device_t intel_flash_bxt_device;
|
||||
extern const device_t intel_flash_bxb_device;
|
||||
|
||||
extern const device_t sst_flash_29ee010_device;
|
||||
extern const device_t sst_flash_29ee020_device;
|
||||
extern const device_t sst_flash_39sf010_device;
|
||||
extern const device_t sst_flash_39sf020_device;
|
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Intel 1 Mbit 8-bit flash devices.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Author: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
|
||||
extern const device_t intel_flash_bxt_ami_device;
|
||||
extern const device_t intel_flash_bxt_device;
|
||||
extern const device_t intel_flash_bxb_device;
|
@@ -38,8 +38,7 @@
|
||||
#include <86box/sio.h>
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/scsi_ncr53c8xx.h>
|
||||
#include <86box/machine.h>
|
||||
|
||||
|
@@ -29,9 +29,8 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/spd.h>
|
||||
#include <86box/video.h>
|
||||
|
@@ -30,8 +30,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/spd.h>
|
||||
|
@@ -29,9 +29,8 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/spd.h>
|
||||
#include <86box/video.h>
|
||||
|
@@ -34,8 +34,7 @@
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdc.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/nvr.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/video.h>
|
||||
@@ -100,7 +99,6 @@ machine_at_award_common_init(const machine_t *model)
|
||||
device_add(&fdc_at_device);
|
||||
device_add(&keyboard_ps2_pci_device);
|
||||
device_add(&sio_device);
|
||||
device_add(&intel_flash_bxt_device);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +160,7 @@ machine_at_valuepointp60_init(const machine_t *model)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
machine_at_p5mp3_init(const machine_t *model)
|
||||
{
|
||||
@@ -175,11 +174,13 @@ machine_at_p5mp3_init(const machine_t *model)
|
||||
|
||||
machine_at_award_common_init(model);
|
||||
|
||||
device_add(&catalyst_flash_device);
|
||||
device_add(&i430lx_device);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
machine_at_586mc1_init(const machine_t *model)
|
||||
{
|
||||
@@ -193,6 +194,7 @@ machine_at_586mc1_init(const machine_t *model)
|
||||
|
||||
machine_at_award_common_init(model);
|
||||
|
||||
device_add(&intel_flash_bxt_device);
|
||||
device_add(&i430lx_device);
|
||||
|
||||
return ret;
|
||||
@@ -250,6 +252,7 @@ machine_at_430nx_init(const machine_t *model)
|
||||
|
||||
machine_at_award_common_init(model);
|
||||
|
||||
device_add(&intel_flash_bxt_device);
|
||||
device_add(&i430nx_device);
|
||||
|
||||
return ret;
|
||||
@@ -416,6 +419,7 @@ machine_at_mb500n_init(const machine_t *model)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEV_BRANCH) && defined(USE_VECTRA54)
|
||||
int
|
||||
machine_at_vectra54_init(const machine_t *model)
|
||||
|
@@ -33,9 +33,8 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/spd.h>
|
||||
|
@@ -29,10 +29,8 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/spd.h>
|
||||
#include <86box/video.h>
|
||||
|
@@ -33,9 +33,8 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/intel_flash.h>
|
||||
#include <86box/flash.h>
|
||||
#include <86box/sio.h>
|
||||
#include <86box/sst_flash.h>
|
||||
#include <86box/spd.h>
|
||||
#include <86box/hwm.h>
|
||||
#include <86box/video.h>
|
||||
|
269
src/mem/catalyst_flash.c
Normal file
269
src/mem/catalyst_flash.c
Normal file
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Intel 1 Mbit and 2 Mbit, 8-bit and
|
||||
* 16-bit flash devices.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/nvr.h>
|
||||
#include <86box/plat.h>
|
||||
|
||||
|
||||
#define FLAG_WORD 4
|
||||
#define FLAG_BXB 2
|
||||
#define FLAG_INV_A16 1
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
BLOCK_MAIN1,
|
||||
BLOCK_MAIN2,
|
||||
BLOCK_DATA1,
|
||||
BLOCK_DATA2,
|
||||
BLOCK_BOOT,
|
||||
BLOCKS_NUM
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CMD_SET_READ = 0x00,
|
||||
CMD_READ_SIGNATURE = 0x90,
|
||||
CMD_ERASE = 0x20,
|
||||
CMD_ERASE_CONFIRM = 0x20,
|
||||
CMD_ERASE_VERIFY = 0xA0,
|
||||
CMD_PROGRAM = 0x40,
|
||||
CMD_PROGRAM_VERIFY = 0xC0,
|
||||
CMD_RESET = 0xFF
|
||||
};
|
||||
|
||||
|
||||
typedef struct flash_t
|
||||
{
|
||||
uint8_t command, pad,
|
||||
pad0, pad1,
|
||||
*array;
|
||||
|
||||
mem_mapping_t mapping, mapping_h[2];
|
||||
} flash_t;
|
||||
|
||||
|
||||
static wchar_t flash_path[1024];
|
||||
|
||||
|
||||
static uint8_t
|
||||
flash_read(uint32_t addr, void *p)
|
||||
{
|
||||
flash_t *dev = (flash_t *) p;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
addr &= biosmask;
|
||||
|
||||
switch (dev->command) {
|
||||
case CMD_ERASE_VERIFY:
|
||||
case CMD_PROGRAM_VERIFY:
|
||||
case CMD_RESET:
|
||||
case CMD_SET_READ:
|
||||
ret = dev->array[addr];
|
||||
break;
|
||||
|
||||
case CMD_READ_SIGNATURE:
|
||||
if (addr == 0x00000)
|
||||
ret = 0x31; /* CATALYST */
|
||||
else if (addr == 0x00001)
|
||||
ret = 0xB4; /* 28F010 */
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static uint16_t
|
||||
flash_readw(uint32_t addr, void *p)
|
||||
{
|
||||
flash_t *dev = (flash_t *)p;
|
||||
uint16_t *q;
|
||||
|
||||
addr &= biosmask;
|
||||
|
||||
q = (uint16_t *)&(dev->array[addr]);
|
||||
|
||||
return *q;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t
|
||||
flash_readl(uint32_t addr, void *p)
|
||||
{
|
||||
flash_t *dev = (flash_t *)p;
|
||||
uint32_t *q;
|
||||
|
||||
addr &= biosmask;
|
||||
|
||||
q = (uint32_t *)&(dev->array[addr]);
|
||||
|
||||
return *q;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
flash_write(uint32_t addr, uint8_t val, void *p)
|
||||
{
|
||||
flash_t *dev = (flash_t *) p;
|
||||
|
||||
addr &= biosmask;
|
||||
|
||||
switch (dev->command) {
|
||||
case CMD_ERASE:
|
||||
if (val == CMD_ERASE_CONFIRM)
|
||||
memset(dev->array, 0xff, biosmask + 1);
|
||||
break;
|
||||
|
||||
case CMD_PROGRAM:
|
||||
dev->array[addr] = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
dev->command = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
flash_writew(uint32_t addr, uint16_t val, void *p)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
flash_writel(uint32_t addr, uint32_t val, void *p)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
catalyst_flash_add_mappings(flash_t *dev)
|
||||
{
|
||||
memcpy(dev->array, rom, biosmask + 1);
|
||||
|
||||
mem_mapping_add(&dev->mapping, 0xe0000, 0x20000,
|
||||
flash_read, flash_readw, flash_readl,
|
||||
flash_write, flash_writew, flash_writel,
|
||||
dev->array, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROMCS, (void *) dev);
|
||||
|
||||
mem_mapping_add(&(dev->mapping_h[0]), 0xfffc0000, 0x20000,
|
||||
flash_read, flash_readw, flash_readl,
|
||||
flash_write, flash_writew, flash_writel,
|
||||
dev->array, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROMCS, (void *) dev);
|
||||
mem_mapping_add(&(dev->mapping_h[1]), 0xfffe0000, 0x20000,
|
||||
flash_read, flash_readw, flash_readl,
|
||||
flash_write, flash_writew, flash_writel,
|
||||
dev->array, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROMCS, (void *) dev);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
catalyst_flash_reset(void *priv)
|
||||
{
|
||||
flash_t *dev = (flash_t *) priv;
|
||||
|
||||
dev->command = CMD_RESET;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
catalyst_flash_init(const device_t *info)
|
||||
{
|
||||
FILE *f;
|
||||
int l;
|
||||
flash_t *dev;
|
||||
wchar_t *machine_name, *flash_name;
|
||||
|
||||
dev = malloc(sizeof(flash_t));
|
||||
memset(dev, 0, sizeof(flash_t));
|
||||
|
||||
l = strlen(machine_get_internal_name_ex(machine))+1;
|
||||
machine_name = (wchar_t *) malloc(l * sizeof(wchar_t));
|
||||
mbstowcs(machine_name, machine_get_internal_name_ex(machine), l);
|
||||
l = wcslen(machine_name)+5;
|
||||
flash_name = (wchar_t *)malloc(l*sizeof(wchar_t));
|
||||
swprintf(flash_name, l, L"%ls.bin", machine_name);
|
||||
|
||||
if (wcslen(flash_name) <= 1024)
|
||||
wcscpy(flash_path, flash_name);
|
||||
else
|
||||
wcsncpy(flash_path, flash_name, 1024);
|
||||
|
||||
mem_mapping_disable(&bios_mapping);
|
||||
mem_mapping_disable(&bios_high_mapping);
|
||||
|
||||
dev->array = (uint8_t *) malloc(0x20000);
|
||||
memset(dev->array, 0xff, 0x20000);
|
||||
|
||||
catalyst_flash_add_mappings(dev);
|
||||
|
||||
dev->command = CMD_RESET;
|
||||
|
||||
f = nvr_fopen(flash_path, L"rb");
|
||||
if (f) {
|
||||
fread(dev->array, 0x20000, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
free(flash_name);
|
||||
free(machine_name);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
catalyst_flash_close(void *p)
|
||||
{
|
||||
FILE *f;
|
||||
flash_t *dev = (flash_t *)p;
|
||||
|
||||
f = nvr_fopen(flash_path, L"wb");
|
||||
fwrite(dev->array, 0x20000, 1, f);
|
||||
fclose(f);
|
||||
|
||||
free(dev->array);
|
||||
dev->array = NULL;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
||||
const device_t catalyst_flash_device =
|
||||
{
|
||||
"Catalyst 28F010-D Flash BIOS",
|
||||
DEVICE_PCI,
|
||||
0,
|
||||
catalyst_flash_init,
|
||||
catalyst_flash_close,
|
||||
catalyst_flash_reset,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
@@ -463,6 +463,9 @@ intel_flash_close(void *p)
|
||||
fwrite(&(dev->array[dev->block_start[BLOCK_DATA2]]), dev->block_len[BLOCK_DATA2], 1, f);
|
||||
fclose(f);
|
||||
|
||||
free(dev->array);
|
||||
dev->array = NULL;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
@@ -552,7 +552,7 @@ MAINOBJ := pc.o config.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
|
||||
usb.o device.o nvr.o nvr_at.o nvr_ps2.o \
|
||||
$(VNCOBJ)
|
||||
|
||||
MEMOBJ := intel_flash.o mem.o rom.o spd.o sst_flash.o
|
||||
MEMOBJ := catalyst_flash.o intel_flash.o mem.o rom.o spd.o sst_flash.o
|
||||
|
||||
CPUOBJ := cpu.o cpu_table.o \
|
||||
808x.o 386.o 386_common.o 386_dynarec.o 386_dynarec_ops.o $(CGTOBJ) \
|
||||
|
Reference in New Issue
Block a user