Added QEMU's fifo8 code.
Added the NCR 53c90 SCSI MCA card and reworked the AMD PCscsi/Tekram DC390 code to use a better port.
This commit is contained in:
parent
ae128ebb0e
commit
688748adbe
@ -35,7 +35,7 @@ endif()
|
|||||||
# WIN32 marks us as a GUI app on Windows
|
# WIN32 marks us as a GUI app on Windows
|
||||||
# MACOSX_BUNDLE prepares a macOS application bundle including with the app icon
|
# MACOSX_BUNDLE prepares a macOS application bundle including with the app icon
|
||||||
add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
|
add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
|
||||||
dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c
|
dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c fifo8.c
|
||||||
device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX})
|
device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX})
|
||||||
|
|
||||||
if(CPPTHREADS)
|
if(CPPTHREADS)
|
||||||
|
116
src/fifo8.c
Normal file
116
src/fifo8.c
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Generic FIFO component, implemented as a circular buffer.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Peter A. G. Crosthwaite
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <86box/86box.h>
|
||||||
|
#include <86box/fifo8.h>
|
||||||
|
|
||||||
|
void fifo8_create(Fifo8 *fifo, uint32_t capacity)
|
||||||
|
{
|
||||||
|
fifo->data = (uint8_t *)malloc(capacity);
|
||||||
|
memset(fifo->data, 0, capacity);
|
||||||
|
fifo->capacity = capacity;
|
||||||
|
fifo->head = 0;
|
||||||
|
fifo->num = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fifo8_destroy(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
if (fifo->data) {
|
||||||
|
free(fifo->data);
|
||||||
|
fifo->data = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fifo8_push(Fifo8 *fifo, uint8_t data)
|
||||||
|
{
|
||||||
|
assert(fifo->num < fifo->capacity);
|
||||||
|
fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data;
|
||||||
|
fifo->num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num)
|
||||||
|
{
|
||||||
|
uint32_t start, avail;
|
||||||
|
|
||||||
|
assert(fifo->num + num <= fifo->capacity);
|
||||||
|
|
||||||
|
start = (fifo->head + fifo->num) % fifo->capacity;
|
||||||
|
|
||||||
|
if (start + num <= fifo->capacity) {
|
||||||
|
memcpy(&fifo->data[start], data, num);
|
||||||
|
} else {
|
||||||
|
avail = fifo->capacity - start;
|
||||||
|
memcpy(&fifo->data[start], data, avail);
|
||||||
|
memcpy(&fifo->data[0], &data[avail], num - avail);
|
||||||
|
}
|
||||||
|
|
||||||
|
fifo->num += num;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo8_pop(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
uint8_t ret;
|
||||||
|
|
||||||
|
assert(fifo->num > 0);
|
||||||
|
ret = fifo->data[fifo->head++];
|
||||||
|
fifo->head %= fifo->capacity;
|
||||||
|
fifo->num--;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num)
|
||||||
|
{
|
||||||
|
uint8_t *ret;
|
||||||
|
|
||||||
|
assert(max > 0 && max <= fifo->num);
|
||||||
|
*num = MIN(fifo->capacity - fifo->head, max);
|
||||||
|
ret = &fifo->data[fifo->head];
|
||||||
|
fifo->head += *num;
|
||||||
|
fifo->head %= fifo->capacity;
|
||||||
|
fifo->num -= *num;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fifo8_reset(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
fifo->num = 0;
|
||||||
|
fifo->head = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fifo8_is_empty(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
return (fifo->num == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fifo8_is_full(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
return (fifo->num == fifo->capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t fifo8_num_free(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
return fifo->capacity - fifo->num;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t fifo8_num_used(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
return fifo->num;
|
||||||
|
}
|
||||||
|
|
149
src/include/86box/fifo8.h
Normal file
149
src/include/86box/fifo8.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
#ifndef EMU_FIFO8_H
|
||||||
|
#define EMU_FIFO8_H
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* All fields are private */
|
||||||
|
uint8_t *data;
|
||||||
|
uint32_t capacity;
|
||||||
|
uint32_t head;
|
||||||
|
uint32_t num;
|
||||||
|
} Fifo8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_create:
|
||||||
|
* @fifo: struct Fifo8 to initialise with new FIFO
|
||||||
|
* @capacity: capacity of the newly created FIFO
|
||||||
|
*
|
||||||
|
* Create a FIFO of the specified size. Clients should call fifo8_destroy()
|
||||||
|
* when finished using the fifo. The FIFO is initially empty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void fifo8_create(Fifo8 *fifo, uint32_t capacity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_destroy:
|
||||||
|
* @fifo: FIFO to cleanup
|
||||||
|
*
|
||||||
|
* Cleanup a FIFO created with fifo8_create(). Frees memory created for FIFO
|
||||||
|
*storage. The FIFO is no longer usable after this has been called.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void fifo8_destroy(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_push:
|
||||||
|
* @fifo: FIFO to push to
|
||||||
|
* @data: data byte to push
|
||||||
|
*
|
||||||
|
* Push a data byte to the FIFO. Behaviour is undefined if the FIFO is full.
|
||||||
|
* Clients are responsible for checking for fullness using fifo8_is_full().
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void fifo8_push(Fifo8 *fifo, uint8_t data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_push_all:
|
||||||
|
* @fifo: FIFO to push to
|
||||||
|
* @data: data to push
|
||||||
|
* @size: number of bytes to push
|
||||||
|
*
|
||||||
|
* Push a byte array to the FIFO. Behaviour is undefined if the FIFO is full.
|
||||||
|
* Clients are responsible for checking the space left in the FIFO using
|
||||||
|
* fifo8_num_free().
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_pop:
|
||||||
|
* @fifo: fifo to pop from
|
||||||
|
*
|
||||||
|
* Pop a data byte from the FIFO. Behaviour is undefined if the FIFO is empty.
|
||||||
|
* Clients are responsible for checking for emptyness using fifo8_is_empty().
|
||||||
|
*
|
||||||
|
* Returns: The popped data byte.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint8_t fifo8_pop(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_pop_buf:
|
||||||
|
* @fifo: FIFO to pop from
|
||||||
|
* @max: maximum number of bytes to pop
|
||||||
|
* @num: actual number of returned bytes
|
||||||
|
*
|
||||||
|
* Pop a number of elements from the FIFO up to a maximum of max. The buffer
|
||||||
|
* containing the popped data is returned. This buffer points directly into
|
||||||
|
* the FIFO backing store and data is invalidated once any of the fifo8_* APIs
|
||||||
|
* are called on the FIFO.
|
||||||
|
*
|
||||||
|
* The function may return fewer bytes than requested when the data wraps
|
||||||
|
* around in the ring buffer; in this case only a contiguous part of the data
|
||||||
|
* is returned.
|
||||||
|
*
|
||||||
|
* The number of valid bytes returned is populated in *num; will always return
|
||||||
|
* at least 1 byte. max must not be 0 or greater than the number of bytes in
|
||||||
|
* the FIFO.
|
||||||
|
*
|
||||||
|
* Clients are responsible for checking the availability of requested data
|
||||||
|
* using fifo8_num_used().
|
||||||
|
*
|
||||||
|
* Returns: A pointer to popped data.
|
||||||
|
*/
|
||||||
|
extern const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_reset:
|
||||||
|
* @fifo: FIFO to reset
|
||||||
|
*
|
||||||
|
* Reset a FIFO. All data is discarded and the FIFO is emptied.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void fifo8_reset(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_is_empty:
|
||||||
|
* @fifo: FIFO to check
|
||||||
|
*
|
||||||
|
* Check if a FIFO is empty.
|
||||||
|
*
|
||||||
|
* Returns: True if the fifo is empty, false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int fifo8_is_empty(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_is_full:
|
||||||
|
* @fifo: FIFO to check
|
||||||
|
*
|
||||||
|
* Check if a FIFO is full.
|
||||||
|
*
|
||||||
|
* Returns: True if the fifo is full, false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int fifo8_is_full(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_num_free:
|
||||||
|
* @fifo: FIFO to check
|
||||||
|
*
|
||||||
|
* Return the number of free bytes in the FIFO.
|
||||||
|
*
|
||||||
|
* Returns: Number of free bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32_t fifo8_num_free(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_num_used:
|
||||||
|
* @fifo: FIFO to check
|
||||||
|
*
|
||||||
|
* Return the number of used bytes in the FIFO.
|
||||||
|
*
|
||||||
|
* Returns: Number of used bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32_t fifo8_num_used(Fifo8 *fifo);
|
||||||
|
|
||||||
|
#endif /* EMU_FIFO8_H */
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern const device_t dc390_pci_device;
|
extern const device_t dc390_pci_device;
|
||||||
|
extern const device_t ncr53c90_mca_device;
|
||||||
|
|
||||||
|
|
||||||
#endif /*SCSI_BUSLOGIC_H*/
|
#endif /*SCSI_BUSLOGIC_H*/
|
||||||
|
@ -72,11 +72,11 @@ static SCSI_CARD scsi_cards[] = {
|
|||||||
{ "t128", &scsi_t128_device, },
|
{ "t128", &scsi_t128_device, },
|
||||||
{ "t130b", &scsi_t130b_device, },
|
{ "t130b", &scsi_t130b_device, },
|
||||||
#ifdef WALTJE
|
#ifdef WALTJE
|
||||||
{ "scsiat", &scsi_scsiat_device, },
|
|
||||||
{ "wd33c93", &scsi_wd33c93_device, },
|
{ "wd33c93", &scsi_wd33c93_device, },
|
||||||
#endif
|
#endif
|
||||||
{ "aha1640", &aha1640_device, },
|
{ "aha1640", &aha1640_device, },
|
||||||
{ "bt640a", &buslogic_640a_device, },
|
{ "bt640a", &buslogic_640a_device, },
|
||||||
|
{ "ncr53c90", &ncr53c90_mca_device, },
|
||||||
{ "spock", &spock_device, },
|
{ "spock", &spock_device, },
|
||||||
{ "bt958d", &buslogic_pci_device, },
|
{ "bt958d", &buslogic_pci_device, },
|
||||||
{ "ncr53c810", &ncr53c810_pci_device, },
|
{ "ncr53c810", &ncr53c810_pci_device, },
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -474,7 +474,7 @@ CXXFLAGS := $(CFLAGS)
|
|||||||
# Create the (final) list of objects to build. #
|
# Create the (final) list of objects to build. #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
MAINOBJ := 86box.o config.o log.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
|
MAINOBJ := 86box.o config.o log.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
|
||||||
nmi.o pic.o pit.o port_6x.o port_92.o ppi.o pci.o mca.o \
|
nmi.o pic.o pit.o port_6x.o port_92.o ppi.o pci.o mca.o fifo8.o \
|
||||||
usb.o device.o nvr.o nvr_at.o nvr_ps2.o \
|
usb.o device.o nvr.o nvr_at.o nvr_ps2.o \
|
||||||
$(VNCOBJ)
|
$(VNCOBJ)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user