Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change fujiF5() to be a macro instead of an entire function. #21

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions fujicom/fujicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}

Expand All @@ -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)
{
Expand All @@ -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
68 changes: 66 additions & 2 deletions fujicom/fujicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef _FUJICOM_H
#define _FUJICOM_H

#undef FUJIF5_AS_FUNCTION

#include <stdint.h>

#define FUJINET_INT 0xF5
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down