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

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

Added floppy drive emulation over the serial connection (MODULE_SERIAL_FLOPPY). Along the way, various optimizations were made to stay within the 8K ROM size target. Also, serial code now returns the number of sectors transferred.

File size: 2.0 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
11void log( int level, char *message, ... );
12
13unsigned long GetTime(void);
14unsigned long GetTime_Timeout(void);
15
16unsigned short checksum( unsigned short *wbuff, int wlen );
17
18class Image
19{
20public:
21    virtual void seekSector( unsigned long lba ) = 0;
22
23    virtual void writeSector( void *buff ) = 0;
24
25    virtual void readSector( void *buff ) = 0;
26
27    Image( char *name, int p_readOnly, int p_drive );
28    Image( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_lba );
29    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 );
30
31    virtual ~Image() {};
32
33    unsigned long cyl, sect, head;
34    unsigned char floppy, floppyType;
35    int useCHS;
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_head, unsigned long *p_sect );
44
45    void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan );
46
47    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 );
48};
49
50struct baudRate {
51    unsigned long rate;
52    unsigned char divisor;
53    char *display;
54};
55struct baudRate *baudRateMatchString( char *str );
56struct baudRate *baudRateMatchDivisor( unsigned char divisor );
57
58#ifdef WIN32
59#include "../win32/win32serial.h"
60#else
61// there is no standard way to read/write and configure the serial port, OS specific only
62#endif
63
64#ifdef WIN32
65#include "../win32/win32file.h"
66#else
67#include "file.h"
68#endif
69
70void processRequests( SerialAccess *serial, Image *image0, Image *image1, int timeoutEnabled, int verboseLevel );
71
72#endif
Note: See TracBrowser for help on using the repository browser.