1 | //====================================================================== |
---|
2 | // |
---|
3 | // Project: XTIDE Universal BIOS, Serial Port Server |
---|
4 | // |
---|
5 | // File: library.h - Include file for users of the library |
---|
6 | // |
---|
7 | |
---|
8 | #ifndef LIBRARY_H_INCLUDED |
---|
9 | #define LIBRARY_H_INCLUDED |
---|
10 | |
---|
11 | #define SERIAL_SERVER_MAJORVERSION 1 |
---|
12 | #define SERIAL_SERVER_MINORVERSION 0 |
---|
13 | |
---|
14 | void log( int level, char *message, ... ); |
---|
15 | |
---|
16 | unsigned long GetTime(void); |
---|
17 | unsigned long GetTime_Timeout(void); |
---|
18 | |
---|
19 | unsigned short checksum( unsigned short *wbuff, int wlen ); |
---|
20 | |
---|
21 | struct floppyInfo { |
---|
22 | unsigned char real; |
---|
23 | unsigned long size; |
---|
24 | unsigned char type; |
---|
25 | unsigned char cylinders; |
---|
26 | unsigned char heads; |
---|
27 | unsigned char sectors; |
---|
28 | }; |
---|
29 | |
---|
30 | struct floppyInfo *FindFloppyInfoBySize( double size ); |
---|
31 | |
---|
32 | class Image |
---|
33 | { |
---|
34 | public: |
---|
35 | virtual void seekSector( unsigned long lba ) = 0; |
---|
36 | |
---|
37 | virtual void writeSector( void *buff ) = 0; |
---|
38 | |
---|
39 | virtual void readSector( void *buff ) = 0; |
---|
40 | |
---|
41 | Image( char *name, int p_readOnly, int p_drive ); |
---|
42 | Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_lba ); |
---|
43 | Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_cyl, unsigned long p_head, unsigned long p_sect, int p_useCHS ); |
---|
44 | |
---|
45 | virtual ~Image() {}; |
---|
46 | |
---|
47 | unsigned long cyl, sect, head; |
---|
48 | unsigned char floppy, floppyType; |
---|
49 | int useCHS; |
---|
50 | |
---|
51 | unsigned long totallba; |
---|
52 | |
---|
53 | char *shortFileName; |
---|
54 | int readOnly; |
---|
55 | int drive; |
---|
56 | |
---|
57 | static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_head, unsigned long *p_sect ); |
---|
58 | |
---|
59 | void respondInquire( unsigned short *buff, unsigned short originalPortAndBaud, struct baudRate *baudRate, unsigned short port, unsigned char scan ); |
---|
60 | |
---|
61 | void init( char *name, int p_readOnly, int p_drive, unsigned long p_cyl, unsigned long p_head, unsigned long p_sect, int p_useCHS ); |
---|
62 | }; |
---|
63 | |
---|
64 | struct baudRate { |
---|
65 | unsigned long rate; |
---|
66 | unsigned char divisor; |
---|
67 | char *display; |
---|
68 | }; |
---|
69 | struct baudRate *baudRateMatchString( char *str ); |
---|
70 | struct baudRate *baudRateMatchDivisor( unsigned char divisor ); |
---|
71 | |
---|
72 | #ifdef WIN32 |
---|
73 | #include "../win32/win32serial.h" |
---|
74 | #else |
---|
75 | // there is no standard way to read/write and configure the serial port, OS specific only |
---|
76 | #endif |
---|
77 | |
---|
78 | #ifdef WIN32 |
---|
79 | #include "../win32/win32file.h" |
---|
80 | #else |
---|
81 | #include "file.h" |
---|
82 | #endif |
---|
83 | |
---|
84 | void processRequests( SerialAccess *serial, Image *image0, Image *image1, int timeoutEnabled, int verboseLevel ); |
---|
85 | |
---|
86 | #endif |
---|