network: allow to set a NIC's link from the status bar

This commit is contained in:
Adrien Moulin
2022-08-27 19:08:28 +02:00
parent c0b6c55926
commit ea21790fc9
16 changed files with 202 additions and 67 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_active_t net[NET_CARD_MAX];
dev_status_empty_t cartridge[2];
} machine_status_t;

View File

@@ -65,6 +65,17 @@
#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,
@@ -84,14 +95,14 @@ 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 {
@@ -121,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;
@@ -132,6 +141,9 @@ struct _netcard_t {
pc_timer_t timer;
int card_num;
double byte_period;
uint32_t led_timer;
uint32_t led_state;
uint32_t link_state;
};
typedef struct {
@@ -152,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);
@@ -161,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);