source: xtideuniversalbios/trunk/Serial_Server/library/Library.h @ 218

Last change on this file since 218 was 217, checked in by gregli@…, 12 years ago

Serial Server: various improvements, turned on LBA28 support by default.

File size: 2.3 KB
Line 
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
13void log( int level, char *message, ... );
14unsigned long GetTime(void);
15unsigned long GetTime_Timeout(void);
16
17unsigned short checksum( unsigned short *wbuff, int wlen );
18
19class Image
20{
21public:
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_head, unsigned long p_sect, int p_useCHS );
32
33    virtual ~Image() {};
34
35    unsigned long cyl, sect, head;
36    int useCHS;
37
38    unsigned long totallba;
39   
40    char *shortFileName;
41    int readOnly;
42    int drive;
43
44    static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_head, unsigned long *p_sect );
45
46    void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned char portAndBaud );
47
48    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 );
49};
50
51struct baudRate {
52    unsigned long rate;
53    unsigned char divisor;
54    char *display;
55};
56struct baudRate *baudRateMatchString( char *str );
57struct baudRate *baudRateMatchDivisor( unsigned char divisor );
58
59class Serial
60{
61public:
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
81void 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
Note: See TracBrowser for help on using the repository browser.