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 | void log( int level, char *message, ... ); |
---|
12 | |
---|
13 | unsigned long GetTime(void); |
---|
14 | unsigned long GetTime_Timeout(void); |
---|
15 | |
---|
16 | unsigned short checksum( unsigned short *wbuff, int wlen ); |
---|
17 | |
---|
18 | class Image |
---|
19 | { |
---|
20 | public: |
---|
21 | virtual void seekSector( unsigned long lba ) = 0; |
---|
22 | |
---|
23 | virtual void writeSector( void *buff ) = 0; |
---|
24 | |
---|
25 | virtual void readSector( void *buff ) = 0; |
---|
26 | |
---|
27 | Image( char *name, int p_readOnly, int p_drive ); |
---|
28 | Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_lba ); |
---|
29 | 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 ); |
---|
30 | |
---|
31 | virtual ~Image() {}; |
---|
32 | |
---|
33 | unsigned long cyl, sect, head; |
---|
34 | int useCHS; |
---|
35 | |
---|
36 | unsigned long totallba; |
---|
37 | |
---|
38 | char *shortFileName; |
---|
39 | int readOnly; |
---|
40 | int drive; |
---|
41 | |
---|
42 | static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_head, unsigned long *p_sect ); |
---|
43 | |
---|
44 | void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan ); |
---|
45 | |
---|
46 | 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 ); |
---|
47 | }; |
---|
48 | |
---|
49 | struct baudRate { |
---|
50 | unsigned long rate; |
---|
51 | unsigned char divisor; |
---|
52 | char *display; |
---|
53 | }; |
---|
54 | struct baudRate *baudRateMatchString( char *str ); |
---|
55 | struct baudRate *baudRateMatchDivisor( unsigned char divisor ); |
---|
56 | |
---|
57 | #ifdef WIN32 |
---|
58 | #include "../win32/win32serial.h" |
---|
59 | #else |
---|
60 | // there is no standard way to read/write and configure the serial port, OS specific only |
---|
61 | #endif |
---|
62 | |
---|
63 | #ifdef WIN32 |
---|
64 | #include "../win32/win32file.h" |
---|
65 | #else |
---|
66 | #include "file.h" |
---|
67 | #endif |
---|
68 | |
---|
69 | void processRequests( SerialAccess *serial, Image *image0, Image *image1, int timeoutEnabled, int verboseLevel ); |
---|
70 | |
---|
71 | #endif |
---|