Merge remote-tracking branch 'upstream/master' into feature/ich2

This commit is contained in:
Jasmine Iwanek
2022-08-31 00:41:04 -04:00
23 changed files with 493 additions and 164 deletions

View File

@@ -21,7 +21,7 @@ typedef struct {
dev_status_empty_active_t mo[MO_NUM];
dev_status_empty_active_t cassette;
dev_status_active_t hdd[HDD_BUS_USB];
dev_status_active_t net;
dev_status_empty_active_t net[NET_CARD_MAX];
dev_status_empty_t cartridge[2];
} machine_status_t;

View File

@@ -96,8 +96,10 @@ extern const device_t rtmidi_input_device;
extern const device_t fluidsynth_device;
# endif
# ifdef USE_MUNT
extern const device_t mt32_device;
extern const device_t mt32_old_device;
extern const device_t mt32_new_device;
extern const device_t cm32l_device;
extern const device_t cm32ln_device;
# endif
#endif

View File

@@ -56,10 +56,26 @@
#define NET_TYPE_PCAP 2 /* use the (Win)Pcap API */
#define NET_MAX_FRAME 1518
#define NET_QUEUE_LEN 8
/* Queue size must be a power of 2 */
#define NET_QUEUE_LEN 16
#define NET_QUEUE_LEN_MASK (NET_QUEUE_LEN - 1)
#define NET_CARD_MAX 4
#define NET_HOST_INTF_MAX 64
#define NET_PERIOD_10M 0.8
#define NET_PERIOD_100M 0.08
enum {
NET_LINK_DOWN = (1 << 1),
NET_LINK_TEMP_DOWN = (1 << 2),
NET_LINK_10_HD = (1 << 3),
NET_LINK_10_FD = (1 << 4),
NET_LINK_100_HD = (1 << 5),
NET_LINK_100_FD = (1 << 6),
NET_LINK_1000_HD = (1 << 7),
NET_LINK_1000_FD = (1 << 8),
};
/* Supported network cards. */
enum {
NONE = 0,
@@ -79,25 +95,23 @@ typedef struct {
int device_num;
int net_type;
char host_dev_name[128];
uint32_t link_state;
} netcard_conf_t;
extern netcard_conf_t net_cards_conf[NET_CARD_MAX];
extern int net_card_current;
typedef int (*NETRXCB)(void *, uint8_t *, int);
typedef int (*NETWAITCB)(void *);
typedef int (*NETSETLINKSTATE)(void *);
typedef int (*NETSETLINKSTATE)(void *, uint32_t link_state);
typedef struct netpkt {
uint8_t *data;
int len;
uint64_t tsc;
} netpkt_t;
typedef struct {
netpkt_t packets[NET_QUEUE_LEN];
int size;
int head;
int tail;
} netqueue_t;
@@ -118,9 +132,7 @@ struct _netcard_t {
const device_t *device;
void *card_drv;
struct netdrv_t host_drv;
int (*poll)(void *);
NETRXCB rx;
NETWAITCB wait;
NETSETLINKSTATE set_link_state;
netqueue_t queues[3];
netpkt_t queued_pkt;
@@ -128,6 +140,10 @@ struct _netcard_t {
mutex_t *rx_mutex;
pc_timer_t timer;
int card_num;
double byte_period;
uint32_t led_timer;
uint32_t led_state;
uint32_t link_state;
};
typedef struct {
@@ -148,7 +164,7 @@ extern netdev_t network_devs[NET_HOST_INTF_MAX];
/* Function prototypes. */
extern void network_init(void);
extern netcard_t *network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKSTATE set_link_state);
extern netcard_t *network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_link_state);
extern void netcard_close(netcard_t *card);
extern void network_close(void);
extern void network_reset(void);
@@ -157,6 +173,9 @@ extern void network_tx(netcard_t *card, uint8_t *, int);
extern int net_pcap_prepare(netdev_t *);
extern void network_connect(int id, int connect);
extern int network_is_connected(int id);
extern int network_dev_available(int);
extern int network_dev_to_id(char *);
extern int network_card_available(int);
extern int network_card_has_config(int);
@@ -165,7 +184,9 @@ extern int network_card_get_from_internal_name(char *);
extern const device_t *network_card_getdevice(int);
extern int network_tx_pop(netcard_t *card, netpkt_t *out_pkt);
extern int network_tx_popv(netcard_t *card, netpkt_t *pkt_vec, int vec_size);
extern int network_rx_put(netcard_t *card, uint8_t *bufp, int len);
extern int network_rx_put_pkt(netcard_t *card, netpkt_t *pkt);
#ifdef __cplusplus
}
#endif