nmc93cxx: Rewrite the nmc93cxx emulation

This patch rewrites the nmc93cxx emulation code.
The primary aim of the rewrite is to fix the Qlogic 1080 BIOS v1.11 flashing feature
(the card utilizes a 93C56 chip in 128x16 mode).

This work is derived from the MAME serial EEPROM emulation code
written by Aaron Giles and published under BSD-3-Clause license.
https://github.com/mamedev/mame/blob/master/src/devices/machine/eepromser.cpp

The code is modelled on the MAME code with the following differences:
- Removed support for the ER5911 and MSM16911 EEPROM devices.
- Removed support for the X24C44 NOVRAM device.
- Removed support for the Seiko S-29X90 EEPROM devices.

The 86Box changes:
- The nmc93cxx code now also supports EEPROM devices in 8-bit mode.
- Make the default_content parameter optional.
- Make the nmc93cxx_eeprom_data function to return a const pointer.
This commit is contained in:
Dmitry Borisov
2026-01-25 08:40:56 +06:00
parent f491069512
commit ca37758018
7 changed files with 669 additions and 229 deletions

View File

@@ -1,25 +1,72 @@
#include <86box/vid_ati_eeprom.h>
/*
* 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.
*
* Header of the emulation of the National Semiconductors NMC93Cxx EEPROMs
* (16 bits or 8 bits).
*
* Authors: Cacodemon345
*
* Copyright 2023 Cacodemon345
*/
#pragma once
typedef struct nmc93cxx_eeprom_t {
ati_eeprom_t dev;
uint8_t addrbits;
uint16_t size;
char filename[1024];
} nmc93cxx_eeprom_t;
/* Forward declaration to hide internal device state from users. */
typedef struct nmc93cxx_eeprom_t nmc93cxx_eeprom_t;
/* EEPROM device type used to specify the size of data array. */
typedef enum nmc93cxx_eeprom_type {
/*
* Standard 93CX6 class of 16-bit EEPROMs.
*
* Type / Bits per cell / Number of cells
*/
NMC_93C06_x16_16,
NMC_93C46_x16_64,
NMC_93C56_x16_128,
NMC_93C57_x16_128,
NMC_93C66_x16_256,
NMC_93C76_x16_512,
NMC_93C86_x16_1024,
/*
* Some manufacturers use pin 6 as an "ORG" pin which,
* when pulled low, configures memory for 8-bit accesses.
*
* Type / Bits per cell / Number of cells
*/
NMC_93C46_x8_128,
NMC_93C56_x8_256,
NMC_93C57_x8_256,
NMC_93C66_x8_512,
NMC_93C76_x8_1024,
NMC_93C86_x8_2048,
} nmc93cxx_eeprom_type;
/* EEPROM device parameters. */
typedef struct nmc93cxx_eeprom_params_t {
uint16_t nwords;
char *filename;
uint16_t *default_content;
/* Device type */
nmc93cxx_eeprom_type type;
/* Name of EEPROM image file */
const char *filename;
/*
* Optional pointer to the default data buffer.
* The buffer size should match the size of EEPROM data array specified by nmc93cxx_eeprom_type.
*/
const void *default_content;
} nmc93cxx_eeprom_params_t;
/* Read from the EEPROM. */
uint16_t nmc93cxx_eeprom_read(nmc93cxx_eeprom_t *eeprom);
/* Read the state of the data output (DO) line. */
bool nmc93cxx_eeprom_read(nmc93cxx_eeprom_t *dev);
/* Write to the EEPROM. */
void nmc93cxx_eeprom_write(nmc93cxx_eeprom_t *eeprom, int eecs, int eesk, int eedi);
/* Set the state of the input lines. */
void nmc93cxx_eeprom_write(nmc93cxx_eeprom_t *dev, bool eecs, bool eesk, bool eedi);
/* Get EEPROM data array. */
uint16_t *nmc93cxx_eeprom_data(nmc93cxx_eeprom_t *eeprom);
/* Returns pointer to the current EEPROM data array. */
const uint16_t *nmc93cxx_eeprom_data(nmc93cxx_eeprom_t *dev);
extern const device_t nmc93cxx_device;