[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 | }; |
---|
| 56 | struct baudRate *baudRateMatchString( char *str ); |
---|
| 57 | struct baudRate *baudRateMatchDivisor( unsigned char divisor ); |
---|
| 58 | |
---|
| 59 | class Serial |
---|
| 60 | { |
---|
| 61 | public: |
---|
| 62 | virtual unsigned long readCharacters( void *buff, unsigned long len ) = 0; |
---|
| 63 | |
---|
| 64 | virtual unsigned long writeCharacters( void *buff, unsigned long len ) = 0; |
---|
| 65 | |
---|
| 66 | Serial( char *name, struct baudRate *p_baudRate ) |
---|
| 67 | { |
---|
| 68 | speedEmulation = 0; |
---|
| 69 | resetConnection = 0; |
---|
| 70 | baudRate = p_baudRate; |
---|
| 71 | }; |
---|
| 72 | |
---|
| 73 | virtual ~Serial() {}; |
---|
| 74 | |
---|
| 75 | int speedEmulation; |
---|
| 76 | int resetConnection; |
---|
| 77 | |
---|
| 78 | struct baudRate *baudRate; |
---|
| 79 | }; |
---|
| 80 | |
---|
| 81 | void processRequests( Serial *serial, Image *image0, Image *image1, int timeoutEnabled, int verboseLevel ); |
---|
| 82 | |
---|
| 83 | #define ATA_COMMAND_LBA 0x40 |
---|
| 84 | #define ATA_COMMAND_HEADMASK 0xf |
---|
| 85 | |
---|
| 86 | #define ATA_DriveAndHead_Drive 0x10 |
---|
| 87 | |
---|
| 88 | #endif |
---|