Skip to content

Commit 95af17c

Browse files
FozzTexxtschak909
authored andcommitted
Change fujiF5() to be a macro instead of an entire function.
1 parent d4a5c3b commit 95af17c

File tree

2 files changed

+74
-7
lines changed

2 files changed

+74
-7
lines changed

fujicom/fujicom.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* #FUJINET Low Level Routines
33
*/
44

5-
#define DEBUG
5+
#undef DEBUG
6+
#define INIT_INFO
67

78
#include "fujicom.h"
89
#include "com.h"
910
#include <dos.h>
1011

11-
#ifdef DEBUG
12+
#if defined(DEBUG) || defined(INIT_INFO)
1213
#include "../sys/print.h" // debug
1314
#endif
1415

@@ -39,7 +40,7 @@ void fujicom_init(void)
3940
if (getenv("FUJI_BPS"))
4041
bps = atol(getenv("FUJI_BPS"));
4142

42-
#ifdef DEBUG
43+
#if defined(DEBUG) || defined(INIT_INFO)
4344
consolef("Port: %i BPS: %li\n", comp, (int32_t) bps);
4445
#endif
4546

@@ -249,8 +250,10 @@ int fujicom_command_write(cmdFrame_t far *cmd, void far *ptr, uint16_t len)
249250
/* Wait for COMPLETE/ERROR */
250251
reply = port_getc_nobuf(port, TIMEOUT_SLOW);
251252
if (reply != 'C') {
253+
#if 0
252254
#ifdef DEBUG
253255
consolef("FN write complete fail: 0x%04x\n", reply);
256+
#endif
254257
#endif
255258
}
256259

@@ -270,6 +273,7 @@ void fujicom_done(void)
270273
return;
271274
}
272275

276+
#ifdef FUJIF5_AS_FUNCTION
273277
int fujiF5(uint8_t direction, uint8_t device, uint8_t command,
274278
uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length)
275279
{
@@ -284,7 +288,6 @@ int fujiF5(uint8_t direction, uint8_t device, uint8_t command,
284288
f5regs.x.di = length;
285289

286290
int86x(FUJINET_INT, &f5regs, &f5regs, &f5status);
287-
288291
return f5regs.x.ax;
289292
}
290-
293+
#endif

fujicom/fujicom.h

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef _FUJICOM_H
66
#define _FUJICOM_H
77

8+
#undef FUJIF5_AS_FUNCTION
9+
810
#include <stdint.h>
911

1012
#define FUJINET_INT 0xF5
@@ -45,6 +47,12 @@ typedef union { /* Command Frame */
4547
};
4648
} cmdFrame_t;
4749

50+
typedef struct {
51+
uint16_t bw;
52+
uint8_t connected; /* meaning of this field is inconsistent */
53+
uint8_t error;
54+
} fujiStatus;
55+
4856
typedef struct {
4957
unsigned char hostSlot;
5058
unsigned char mode;
@@ -70,22 +78,66 @@ enum {
7078
};
7179

7280
enum {
81+
CMD_CHDIR = 0x2c,
7382
CMD_OPEN = 'O',
7483
CMD_CLOSE = 'C',
7584
CMD_READ = 'R',
7685
CMD_WRITE = 'W',
7786
CMD_STATUS = 'S',
87+
CMD_PARSE = 'P',
88+
CMD_QUERY = 'Q',
7889
CMD_APETIME_GETTIME = 0x93,
7990
CMD_APETIME_SETTZ = 0x99,
8091
CMD_APETIME_GETTZTIME = 0x9A,
8192
CMD_READ_DEVICE_SLOTS = 0xF2,
93+
CMD_JSON = 0xFC,
8294
CMD_USERNAME = 0xFD,
8395
CMD_PASSWORD = 0xFE,
8496
};
8597

8698
enum {
87-
MODE_READONLY = 1,
88-
MODE_READWRITE = 2,
99+
SLOT_READONLY = 1,
100+
SLOT_READWRITE = 2,
101+
};
102+
103+
enum {
104+
NETWORK_SUCCESS = 1,
105+
NETWORK_ERROR_WRITE_ONLY = 131,
106+
NETWORK_ERROR_INVALID_COMMAND = 132,
107+
NETWORK_ERROR_READ_ONLY = 135,
108+
NETWORK_ERROR_END_OF_FILE = 136,
109+
NETWORK_ERROR_GENERAL_TIMEOUT = 138,
110+
NETWORK_ERROR_GENERAL = 144,
111+
NETWORK_ERROR_NOT_IMPLEMENTED = 146,
112+
NETWORK_ERROR_FILE_EXISTS = 151,
113+
NETWORK_ERROR_NO_SPACE_ON_DEVICE = 162,
114+
NETWORK_ERROR_INVALID_DEVICESPEC = 165,
115+
NETWORK_ERROR_ACCESS_DENIED = 167,
116+
NETWORK_ERROR_FILE_NOT_FOUND = 170,
117+
NETWORK_ERROR_CONNECTION_REFUSED = 200,
118+
NETWORK_ERROR_NETWORK_UNREACHABLE = 201,
119+
NETWORK_ERROR_SOCKET_TIMEOUT = 202,
120+
NETWORK_ERROR_NETWORK_DOWN = 203,
121+
NETWORK_ERROR_CONNECTION_RESET = 204,
122+
NETWORK_ERROR_CONNECTION_ALREADY_IN_PROGRESS = 205,
123+
NETWORK_ERROR_ADDRESS_IN_USE = 206,
124+
NETWORK_ERROR_NOT_CONNECTED = 207,
125+
NETWORK_ERROR_SERVER_NOT_RUNNING = 208,
126+
NETWORK_ERROR_NO_CONNECTION_WAITING = 209,
127+
NETWORK_ERROR_SERVICE_NOT_AVAILABLE = 210,
128+
NETWORK_ERROR_CONNECTION_ABORTED = 211,
129+
NETWORK_ERROR_INVALID_USERNAME_OR_PASSWORD = 212,
130+
NETWORK_ERROR_COULD_NOT_PARSE_JSON = 213,
131+
NETWORK_ERROR_CLIENT_GENERAL = 214,
132+
NETWORK_ERROR_SERVER_GENERAL = 215,
133+
NETWORK_ERROR_NO_DEVICE_AVAILABLE = 216,
134+
NETWORK_ERROR_NOT_A_DIRECTORY = 217,
135+
NETWORK_ERROR_COULD_NOT_ALLOCATE_BUFFERS = 255,
136+
};
137+
138+
enum {
139+
REPLY_ERROR = 'E',
140+
REPLY_COMPLETE = 'C',
89141
};
90142

91143
#define STATUS_MOUNT_TIME 0x01
@@ -130,8 +182,20 @@ extern int fujicom_command_write(cmdFrame_t far *c, void far *ptr, uint16_t len)
130182
*/
131183
void fujicom_done(void);
132184

185+
#ifndef FUJIF5_AS_FUNCTION
186+
extern int fujiF5w(uint16_t direction, uint16_t devcom,
187+
uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length);
188+
#pragma aux fujiF5w = \
189+
"int 0xf5" \
190+
parm [dx] [ax] [cx] [si] [es bx] [di] \
191+
modify [ax]
192+
#define fujiF5(dx, dev, cmd, a12, a34, buf, len) \
193+
fujiF5w(dx, cmd << 8 | dev, a12, a34, buf, len)
194+
#else
133195
extern int fujiF5(uint8_t direction, uint8_t device, uint8_t command,
134196
uint16_t aux12, uint16_t aux34, void far *buffer, uint16_t length);
197+
#endif
198+
135199
#define fujiF5_none(d, c, a12, a34, b, l) fujiF5(FUJIINT_NONE, d, c, a12, a34, b, l)
136200
#define fujiF5_read(d, c, a12, a34, b, l) fujiF5(FUJIINT_READ, d, c, a12, a34, b, l)
137201
#define fujiF5_write(d, c, a12, a34, b, l) fujiF5(FUJIINT_WRITE, d, c, a12, a34, b, l)

0 commit comments

Comments
 (0)