diff --git a/fujicom/fujicom.c b/fujicom/fujicom.c index 3920423..50373f9 100644 --- a/fujicom/fujicom.c +++ b/fujicom/fujicom.c @@ -2,13 +2,14 @@ * #FUJINET Low Level Routines */ -#define DEBUG +#undef DEBUG +#define INIT_INFO #include "fujicom.h" #include "com.h" #include <dos.h> -#ifdef DEBUG +#if defined(DEBUG) || defined(INIT_INFO) #include "../sys/print.h" // debug #endif @@ -39,7 +40,7 @@ void fujicom_init(void) if (getenv("FUJI_BPS")) bps = atol(getenv("FUJI_BPS")); -#ifdef DEBUG +#if defined(DEBUG) || defined(INIT_INFO) consolef("Port: %i BPS: %li\n", comp, (int32_t) bps); #endif @@ -249,8 +250,10 @@ int fujicom_command_write(cmdFrame_t far *cmd, void far *ptr, uint16_t len) /* Wait for COMPLETE/ERROR */ reply = port_getc_nobuf(port, TIMEOUT_SLOW); if (reply != 'C') { +#if 0 #ifdef DEBUG consolef("FN write complete fail: 0x%04x\n", reply); +#endif #endif } @@ -270,6 +273,7 @@ void fujicom_done(void) return; } +#ifdef FUJIF5_AS_FUNCTION int fujiF5(uint8_t direction, uint8_t device, uint8_t command, uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length) { @@ -284,7 +288,6 @@ int fujiF5(uint8_t direction, uint8_t device, uint8_t command, f5regs.x.di = length; int86x(FUJINET_INT, &f5regs, &f5regs, &f5status); - return f5regs.x.ax; } - +#endif diff --git a/fujicom/fujicom.h b/fujicom/fujicom.h index c49eae8..d1afb9e 100644 --- a/fujicom/fujicom.h +++ b/fujicom/fujicom.h @@ -5,6 +5,8 @@ #ifndef _FUJICOM_H #define _FUJICOM_H +#undef FUJIF5_AS_FUNCTION + #include <stdint.h> #define FUJINET_INT 0xF5 @@ -45,6 +47,12 @@ typedef union { /* Command Frame */ }; } cmdFrame_t; +typedef struct { + uint16_t bw; + uint8_t connected; /* meaning of this field is inconsistent */ + uint8_t error; +} fujiStatus; + typedef struct { unsigned char hostSlot; unsigned char mode; @@ -70,22 +78,66 @@ enum { }; enum { + CMD_CHDIR = 0x2c, CMD_OPEN = 'O', CMD_CLOSE = 'C', CMD_READ = 'R', CMD_WRITE = 'W', CMD_STATUS = 'S', + CMD_PARSE = 'P', + CMD_QUERY = 'Q', CMD_APETIME_GETTIME = 0x93, CMD_APETIME_SETTZ = 0x99, CMD_APETIME_GETTZTIME = 0x9A, CMD_READ_DEVICE_SLOTS = 0xF2, + CMD_JSON = 0xFC, CMD_USERNAME = 0xFD, CMD_PASSWORD = 0xFE, }; enum { - MODE_READONLY = 1, - MODE_READWRITE = 2, + SLOT_READONLY = 1, + SLOT_READWRITE = 2, +}; + +enum { + NETWORK_SUCCESS = 1, + NETWORK_ERROR_WRITE_ONLY = 131, + NETWORK_ERROR_INVALID_COMMAND = 132, + NETWORK_ERROR_READ_ONLY = 135, + NETWORK_ERROR_END_OF_FILE = 136, + NETWORK_ERROR_GENERAL_TIMEOUT = 138, + NETWORK_ERROR_GENERAL = 144, + NETWORK_ERROR_NOT_IMPLEMENTED = 146, + NETWORK_ERROR_FILE_EXISTS = 151, + NETWORK_ERROR_NO_SPACE_ON_DEVICE = 162, + NETWORK_ERROR_INVALID_DEVICESPEC = 165, + NETWORK_ERROR_ACCESS_DENIED = 167, + NETWORK_ERROR_FILE_NOT_FOUND = 170, + NETWORK_ERROR_CONNECTION_REFUSED = 200, + NETWORK_ERROR_NETWORK_UNREACHABLE = 201, + NETWORK_ERROR_SOCKET_TIMEOUT = 202, + NETWORK_ERROR_NETWORK_DOWN = 203, + NETWORK_ERROR_CONNECTION_RESET = 204, + NETWORK_ERROR_CONNECTION_ALREADY_IN_PROGRESS = 205, + NETWORK_ERROR_ADDRESS_IN_USE = 206, + NETWORK_ERROR_NOT_CONNECTED = 207, + NETWORK_ERROR_SERVER_NOT_RUNNING = 208, + NETWORK_ERROR_NO_CONNECTION_WAITING = 209, + NETWORK_ERROR_SERVICE_NOT_AVAILABLE = 210, + NETWORK_ERROR_CONNECTION_ABORTED = 211, + NETWORK_ERROR_INVALID_USERNAME_OR_PASSWORD = 212, + NETWORK_ERROR_COULD_NOT_PARSE_JSON = 213, + NETWORK_ERROR_CLIENT_GENERAL = 214, + NETWORK_ERROR_SERVER_GENERAL = 215, + NETWORK_ERROR_NO_DEVICE_AVAILABLE = 216, + NETWORK_ERROR_NOT_A_DIRECTORY = 217, + NETWORK_ERROR_COULD_NOT_ALLOCATE_BUFFERS = 255, +}; + +enum { + REPLY_ERROR = 'E', + REPLY_COMPLETE = 'C', }; #define STATUS_MOUNT_TIME 0x01 @@ -130,8 +182,20 @@ extern int fujicom_command_write(cmdFrame_t far *c, void far *ptr, uint16_t len) */ void fujicom_done(void); +#ifndef FUJIF5_AS_FUNCTION +extern int fujiF5w(uint16_t direction, uint16_t devcom, + uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length); +#pragma aux fujiF5w = \ + "int 0xf5" \ + parm [dx] [ax] [cx] [si] [es bx] [di] \ + modify [ax] +#define fujiF5(dx, dev, cmd, a12, a34, buf, len) \ + fujiF5w(dx, cmd << 8 | dev, a12, a34, buf, len) +#else extern int fujiF5(uint8_t direction, uint8_t device, uint8_t command, uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length); +#endif + #define fujiF5_none(d, c, a12, a34, b, l) fujiF5(FUJIINT_NONE, d, c, a12, a34, b, l) #define fujiF5_read(d, c, a12, a34, b, l) fujiF5(FUJIINT_READ, d, c, a12, a34, b, l) #define fujiF5_write(d, c, a12, a34, b, l) fujiF5(FUJIINT_WRITE, d, c, a12, a34, b, l)