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

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

Initial checkin for the Serial Server code, to be run on a host computer with a hard disk image file. Connected via a serial line, this provides the I/O for the serial port support in the XTIDE bios. At present, this is a Win32 command line program, run without parameters for usage information.

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_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 char *altSelection;
56};
57struct baudRate *baudRateMatchString( char *str );
58struct baudRate *baudRateMatchDivisor( unsigned char divisor );
59
60class Serial
61{
62public:
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
82void 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
Note: See TracBrowser for help on using the repository browser.