Files
net/exec/device.h
2026-01-06 15:51:03 -08:00

102 lines
2.2 KiB
C

#pragma once
#include <stddef.h>
#include <stdint.h>
#include <exec/sync.h>
#include <exec/port.h>
#include <exec/library.h>
#define CMD_INVALID 0
#define CMD_RESET 1
#define CMD_READ 2
#define CMD_WRITE 3
#define CMD_UPDATE 4
#define CMD_CLEAR 5
#define CMD_STOP 6
#define CMD_START 7
#define CMD_FLUSH 8
#define CMD_NONSTD 9
#define NIC_GET_ADDRESS 200
#define NIC_SET_ADDRESS 201
#define NIC_SEND_FRAME 202
#define NIC_REVC_FRAME 203
#define VID_SET_MODE 301
#define VID_GET_FRAMEBUFFER 302
#define DV_OPEN 0
#define DV_CLOSE 1
#define DV_EXPUNGE 2
#define DV_NULL 3
#define DV_BEGINIO 4
#define DV_ABORTIO 5
#define ODE_OK 0
#define ODE_NOTFOUND 1
#define ODE_BADUNIT 2
#define DS_OK 0
#define DS_FAIL 1
#define DS_BADFUN 2
#define DS_TOOSMALL 3
#define IOF_QUICK 1
struct Device {
struct Library library;
};
struct Unit {
struct Port port;
uint8_t flags;
uint8_t pad;
uint16_t open_count;
};
struct IORequest {
struct Message message;
struct Device *dev;
struct Unit *unit;
uint16_t command;
uint8_t flags;
uint8_t error;
};
struct IOStdReq {
struct IORequest ior;
uint32_t reqlen;
uint32_t reslen;
uint32_t offset;
void *data;
};
struct VideoMode {
struct Node node;
uint16_t width;
uint16_t height;
uint8_t bpp;
uint32_t flags;
};
#pragma pack(push,1)
struct DevFuncTable {
uint32_t (*open)(void *_IExec, struct Device *dev, uint32_t unitNumber, struct IORequest *ior, uint32_t flags);
uint32_t (*close)(void);
uint32_t (*expunge)(void);
uint32_t (*null)(void);
uint32_t (*beginio)(struct IORequest *ior);
uint32_t (*abortio)(void);
};
#pragma pack(pop)
void DevicesInit(void);
void AddDevice(struct Device *device);
int OpenDevice(char *devName, uint32_t unitNumber, struct IORequest *ior, uint32_t flags);
uint32_t BeginIO(struct IORequest *ior);
uint32_t WaitIO(struct IORequest *ior);
uint32_t DoIO(struct IORequest *ior);
uint32_t SendIO(struct IORequest *ior);
uint32_t GenericBeginIO(struct IORequest *ior);
struct IORequest *CreateExtIO(struct Port *reply_port, uint32_t size);
struct IOStdReq *CreateStdIO(struct Port *reply_port);
void CompleteIO(struct IORequest *ior);