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

Last change on this file since 216 was 215, checked in by gregli@…, 13 years ago

More minor improvements to the serial server, in particular improved timeout recovery.

File size: 2.2 KB
RevLine 
[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
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_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
47private:
48 void init( char *name, int p_readOnly, int p_drive );
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.