[209] | 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 | #include "stdio.h"
|
---|
| 12 |
|
---|
| 13 | void log( int level, char *message, ... );
|
---|
| 14 | unsigned long GetTime(void);
|
---|
| 15 | unsigned long GetTime_Timeout(void);
|
---|
| 16 |
|
---|
| 17 | unsigned short checksum( unsigned short *wbuff, int wlen );
|
---|
| 18 |
|
---|
| 19 | class Image
|
---|
| 20 | {
|
---|
| 21 | public:
|
---|
| 22 | virtual int seekSector( unsigned long cyl, unsigned long sect, unsigned long head ) = 0;
|
---|
| 23 | virtual int seekSector( unsigned long lba ) = 0;
|
---|
| 24 |
|
---|
| 25 | virtual int writeSector( void *buff ) = 0;
|
---|
| 26 |
|
---|
| 27 | virtual int readSector( void *buff ) = 0;
|
---|
| 28 |
|
---|
| 29 | Image( char *name, int p_readOnly, int p_drive );
|
---|
| 30 | Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_lba );
|
---|
| 31 | Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_cyl, unsigned long p_sect, unsigned long p_head );
|
---|
| 32 |
|
---|
| 33 | virtual ~Image() {};
|
---|
| 34 |
|
---|
| 35 | unsigned long cyl, sect, head;
|
---|
| 36 |
|
---|
| 37 | unsigned long totallba;
|
---|
| 38 |
|
---|
| 39 | char *shortFileName;
|
---|
| 40 | int readOnly;
|
---|
| 41 | int drive;
|
---|
| 42 |
|
---|
| 43 | static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_sect, unsigned long *p_head );
|
---|
| 44 |
|
---|
| 45 | void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned char portAndBaud );
|
---|
| 46 |
|
---|
| 47 | private:
|
---|
| 48 | void init( char *name, int p_readOnly, int p_drive );
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | struct baudRate {
|
---|
| 52 | unsigned long rate;
|
---|
| 53 | unsigned char divisor;
|
---|
| 54 | char *display;
|
---|
| 55 | char *altSelection;
|
---|
| 56 | };
|
---|
| 57 | struct baudRate *baudRateMatchString( char *str );
|
---|
| 58 | struct baudRate *baudRateMatchDivisor( unsigned char divisor );
|
---|
| 59 |
|
---|
| 60 | class Serial
|
---|
| 61 | {
|
---|
| 62 | public:
|
---|
| 63 | virtual unsigned long readCharacters( void *buff, unsigned long len ) = 0;
|
---|
| 64 |
|
---|
| 65 | virtual unsigned long writeCharacters( void *buff, unsigned long len ) = 0;
|
---|
| 66 |
|
---|
| 67 | Serial( char *name, struct baudRate *p_baudRate )
|
---|
| 68 | {
|
---|
| 69 | speedEmulation = 0;
|
---|
| 70 | resetConnection = 0;
|
---|
| 71 | baudRate = p_baudRate;
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | virtual ~Serial() {};
|
---|
| 75 |
|
---|
| 76 | int speedEmulation;
|
---|
| 77 | int resetConnection;
|
---|
| 78 |
|
---|
| 79 | struct baudRate *baudRate;
|
---|
| 80 | };
|
---|
| 81 |
|
---|
| 82 | void processRequests( Serial *serial, Image *image0, Image *image1, int timeoutEnabled, int verboseLevel );
|
---|
| 83 |
|
---|
| 84 | #define ATA_COMMAND_LBA 0x40
|
---|
| 85 | #define ATA_COMMAND_HEADMASK 0xf
|
---|
| 86 |
|
---|
| 87 | #define ATA_DriveAndHead_Drive 0x10
|
---|
| 88 |
|
---|
| 89 | #endif
|
---|