Home » Archimedes archive » Acorn User » AU 1995-04.adf » !Internet_StarterPak » SerialDev/c/driver
SerialDev/c/driver
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1995-04.adf » !Internet_StarterPak |
Filename: | SerialDev/c/driver |
Read OK: | ✔ |
File size: | 0AF7 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/* _____________________________________________ [> <] Project [> ARCterm VII <] Author [> Hugo Fiennes <] Date started [> 05-March-1990 <] [> <] Module name [> Driver loading <] Current version [> 00.04 <] Version date [> 09-December-1992 <] State [> Unfinished <] [> <] [> This source is COPYRIGHT � 1992 by <] [> Hugo Fiennes of The Serial Port <] [>_____________________________________________<] */ #include <stdio.h> #include <string.h> #include "driver.h" #include "os.h" int (*driver)(int,...); int *driver_speedtable,driver_flags,driver_version,driver_noofspeeds; char *driver_info,*driver_creator; drivers_block drivers[16]; extern int driver_block[]; void driver_init() { os_gbpbstr r; char drivername[20],temp[60]; int nd=0; FILE *drvcheck; /* Build table of availiable drivers */ /* Scan directory */ r.action=9; r.file_handle=(int)"<SerialDev$Path>Modules"; r.data_addr=drivername; r.seq_point=0; r.buf_len=20; r.wild_fld=NULL; do { r.number=1; os_gbpb(&r); if (r.number) { /* Got filename, check driver */ sprintf(temp,"<SerialDev$Path>Modules.%s.Driver",drivername); if ((drvcheck=fopen(temp,"rb"))!=NULL) { strcpy(drivers[nd].file,drivername); fseek(drvcheck,0x80,SEEK_SET); fread(drivers[nd].info,1,32,drvcheck); fseek(drvcheck,0xc8,SEEK_SET); fread(&drivers[nd++].number,1,4,drvcheck); fclose(drvcheck); } } } while(r.seq_point>=0); /* Terminate list */ drivers[nd].info[0]=0; } void *driver_load(char *drivername) { FILE *drv; long len; char temp[60]; sprintf(temp,"<SerialDev$Path>Modules.%s.Driver",drivername); if ((drv=fopen(temp,"rb"))==NULL) return(NULL); fseek(drv,0,SEEK_END); len=ftell(drv); fseek(drv,0,SEEK_SET); fread(driver_block,1,len,drv); fclose(drv); /* NOTE! Should really call initialise entry before checking ANY of the below */ driver_flags=driver_block[49]; driver_version=driver_block[48]; driver_speedtable=&driver_block[64]; driver_info=(char*)&driver_block[32]; driver_creator=(char*)&driver_block[40]; driver_noofspeeds=0; while(driver_speedtable[driver_noofspeeds++]); driver_noofspeeds--; return(driver_block); }
00000000 2f 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |/* | 00000010 20 20 20 20 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f | ____________| 00000020 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f |________________| * 00000040 5f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |_. | 00000050 20 20 20 20 5b 3e 20 20 20 20 20 20 20 20 20 20 | [> | 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000080 20 20 20 3c 5d 0a 50 72 6f 6a 65 63 74 20 20 20 | <].Project | 00000090 20 20 20 20 20 20 20 20 5b 3e 20 41 52 43 74 65 | [> ARCte| 000000a0 72 6d 20 56 49 49 20 20 20 20 20 20 20 20 20 20 |rm VII | 000000b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000000c0 20 20 20 20 20 20 20 3c 5d 0a 41 75 74 68 6f 72 | <].Author| 000000d0 20 20 20 20 20 20 20 20 20 20 20 20 5b 3e 20 48 | [> H| 000000e0 75 67 6f 20 46 69 65 6e 6e 65 73 20 20 20 20 20 |ugo Fiennes | 000000f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000100 20 20 20 20 20 20 20 20 20 20 20 3c 5d 0a 44 61 | <].Da| 00000110 74 65 20 73 74 61 72 74 65 64 20 20 20 20 20 20 |te started | 00000120 5b 3e 20 30 35 2d 4d 61 72 63 68 2d 31 39 39 30 |[> 05-March-1990| 00000130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3c | <| 00000150 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |]. | 00000160 20 20 20 20 5b 3e 20 20 20 20 20 20 20 20 20 20 | [> | 00000170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000190 20 20 20 3c 5d 0a 4d 6f 64 75 6c 65 20 6e 61 6d | <].Module nam| 000001a0 65 20 20 20 20 20 20 20 5b 3e 20 44 72 69 76 65 |e [> Drive| 000001b0 72 20 6c 6f 61 64 69 6e 67 20 20 20 20 20 20 20 |r loading | 000001c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000001d0 20 20 20 20 20 20 20 3c 5d 0a 43 75 72 72 65 6e | <].Curren| 000001e0 74 20 76 65 72 73 69 6f 6e 20 20 20 5b 3e 20 30 |t version [> 0| 000001f0 30 2e 30 34 20 20 20 20 20 20 20 20 20 20 20 20 |0.04 | 00000200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000210 20 20 20 20 20 20 20 20 20 20 20 3c 5d 0a 56 65 | <].Ve| 00000220 72 73 69 6f 6e 20 64 61 74 65 20 20 20 20 20 20 |rsion date | 00000230 5b 3e 20 30 39 2d 44 65 63 65 6d 62 65 72 2d 31 |[> 09-December-1| 00000240 39 39 32 20 20 20 20 20 20 20 20 20 20 20 20 20 |992 | 00000250 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3c | <| 00000260 5d 0a 53 74 61 74 65 20 20 20 20 20 20 20 20 20 |].State | 00000270 20 20 20 20 5b 3e 20 55 6e 66 69 6e 69 73 68 65 | [> Unfinishe| 00000280 64 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |d | 00000290 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000002a0 20 20 20 3c 5d 0a 20 20 20 20 20 20 20 20 20 20 | <]. | 000002b0 20 20 20 20 20 20 20 20 5b 3e 20 20 20 20 20 20 | [> | 000002c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000002e0 20 20 20 20 20 20 20 3c 5d 0a 20 20 20 20 20 20 | <]. | 000002f0 20 20 20 20 20 20 20 20 20 20 20 20 5b 3e 20 20 | [> | 00000300 20 20 54 68 69 73 20 73 6f 75 72 63 65 20 69 73 | This source is| 00000310 20 43 4f 50 59 52 49 47 48 54 20 a9 20 31 39 39 | COPYRIGHT . 199| 00000320 32 20 62 79 20 20 20 20 20 20 20 3c 5d 0a 20 20 |2 by <]. | 00000330 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000340 5b 3e 20 20 20 20 20 20 48 75 67 6f 20 46 69 65 |[> Hugo Fie| 00000350 6e 6e 65 73 20 6f 66 20 54 68 65 20 53 65 72 69 |nnes of The Seri| 00000360 61 6c 20 50 6f 72 74 20 20 20 20 20 20 20 20 3c |al Port <| 00000370 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |]. | 00000380 20 20 20 20 5b 3e 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f | [>__________| 00000390 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f |________________| * 000003b0 5f 5f 5f 3c 5d 0a 2a 2f 0a 0a 23 69 6e 63 6c 75 |___<].*/..#inclu| 000003c0 64 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e |de <stdio.h>.#in| 000003d0 63 6c 75 64 65 20 3c 73 74 72 69 6e 67 2e 68 3e |clude <string.h>| 000003e0 0a 23 69 6e 63 6c 75 64 65 20 22 64 72 69 76 65 |.#include "drive| 000003f0 72 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 6f |r.h".#include "o| 00000400 73 2e 68 22 0a 0a 69 6e 74 20 20 28 2a 64 72 69 |s.h"..int (*dri| 00000410 76 65 72 29 28 69 6e 74 2c 2e 2e 2e 29 3b 0a 69 |ver)(int,...);.i| 00000420 6e 74 20 20 2a 64 72 69 76 65 72 5f 73 70 65 65 |nt *driver_spee| 00000430 64 74 61 62 6c 65 2c 64 72 69 76 65 72 5f 66 6c |dtable,driver_fl| 00000440 61 67 73 2c 64 72 69 76 65 72 5f 76 65 72 73 69 |ags,driver_versi| 00000450 6f 6e 2c 64 72 69 76 65 72 5f 6e 6f 6f 66 73 70 |on,driver_noofsp| 00000460 65 65 64 73 3b 0a 63 68 61 72 20 2a 64 72 69 76 |eeds;.char *driv| 00000470 65 72 5f 69 6e 66 6f 2c 2a 64 72 69 76 65 72 5f |er_info,*driver_| 00000480 63 72 65 61 74 6f 72 3b 0a 64 72 69 76 65 72 73 |creator;.drivers| 00000490 5f 62 6c 6f 63 6b 20 64 72 69 76 65 72 73 5b 31 |_block drivers[1| 000004a0 36 5d 3b 0a 0a 65 78 74 65 72 6e 20 69 6e 74 20 |6];..extern int | 000004b0 64 72 69 76 65 72 5f 62 6c 6f 63 6b 5b 5d 3b 0a |driver_block[];.| 000004c0 0a 76 6f 69 64 20 64 72 69 76 65 72 5f 69 6e 69 |.void driver_ini| 000004d0 74 28 29 0a 20 20 7b 0a 20 20 6f 73 5f 67 62 70 |t(). {. os_gbp| 000004e0 62 73 74 72 20 72 3b 20 63 68 61 72 20 64 72 69 |bstr r; char dri| 000004f0 76 65 72 6e 61 6d 65 5b 32 30 5d 2c 74 65 6d 70 |vername[20],temp| 00000500 5b 36 30 5d 3b 0a 20 20 69 6e 74 20 6e 64 3d 30 |[60];. int nd=0| 00000510 3b 0a 20 20 46 49 4c 45 20 2a 64 72 76 63 68 65 |;. FILE *drvche| 00000520 63 6b 3b 0a 0a 20 20 2f 2a 20 42 75 69 6c 64 20 |ck;.. /* Build | 00000530 74 61 62 6c 65 20 6f 66 20 61 76 61 69 6c 69 61 |table of availia| 00000540 62 6c 65 20 64 72 69 76 65 72 73 20 2a 2f 0a 20 |ble drivers */. | 00000550 20 2f 2a 20 53 63 61 6e 20 64 69 72 65 63 74 6f | /* Scan directo| 00000560 72 79 20 2a 2f 0a 20 20 72 2e 61 63 74 69 6f 6e |ry */. r.action| 00000570 3d 39 3b 0a 20 20 72 2e 66 69 6c 65 5f 68 61 6e |=9;. r.file_han| 00000580 64 6c 65 3d 28 69 6e 74 29 22 3c 53 65 72 69 61 |dle=(int)"<Seria| 00000590 6c 44 65 76 24 50 61 74 68 3e 4d 6f 64 75 6c 65 |lDev$Path>Module| 000005a0 73 22 3b 0a 20 20 72 2e 64 61 74 61 5f 61 64 64 |s";. r.data_add| 000005b0 72 3d 64 72 69 76 65 72 6e 61 6d 65 3b 0a 20 20 |r=drivername;. | 000005c0 72 2e 73 65 71 5f 70 6f 69 6e 74 3d 30 3b 20 72 |r.seq_point=0; r| 000005d0 2e 62 75 66 5f 6c 65 6e 3d 32 30 3b 0a 20 20 72 |.buf_len=20;. r| 000005e0 2e 77 69 6c 64 5f 66 6c 64 3d 4e 55 4c 4c 3b 0a |.wild_fld=NULL;.| 000005f0 0a 20 20 64 6f 0a 20 20 20 20 7b 0a 20 20 20 20 |. do. {. | 00000600 72 2e 6e 75 6d 62 65 72 3d 31 3b 20 6f 73 5f 67 |r.number=1; os_g| 00000610 62 70 62 28 26 72 29 3b 0a 20 20 20 20 69 66 20 |bpb(&r);. if | 00000620 28 72 2e 6e 75 6d 62 65 72 29 0a 20 20 20 20 20 |(r.number). | 00000630 20 7b 0a 20 20 20 20 20 20 2f 2a 20 47 6f 74 20 | {. /* Got | 00000640 66 69 6c 65 6e 61 6d 65 2c 20 63 68 65 63 6b 20 |filename, check | 00000650 64 72 69 76 65 72 20 2a 2f 0a 20 20 20 20 20 20 |driver */. | 00000660 73 70 72 69 6e 74 66 28 74 65 6d 70 2c 22 3c 53 |sprintf(temp,"<S| 00000670 65 72 69 61 6c 44 65 76 24 50 61 74 68 3e 4d 6f |erialDev$Path>Mo| 00000680 64 75 6c 65 73 2e 25 73 2e 44 72 69 76 65 72 22 |dules.%s.Driver"| 00000690 2c 64 72 69 76 65 72 6e 61 6d 65 29 3b 0a 20 20 |,drivername);. | 000006a0 20 20 20 20 69 66 20 28 28 64 72 76 63 68 65 63 | if ((drvchec| 000006b0 6b 3d 66 6f 70 65 6e 28 74 65 6d 70 2c 22 72 62 |k=fopen(temp,"rb| 000006c0 22 29 29 21 3d 4e 55 4c 4c 29 0a 20 20 20 20 20 |"))!=NULL). | 000006d0 20 20 20 7b 0a 20 20 20 20 20 20 20 20 73 74 72 | {. str| 000006e0 63 70 79 28 64 72 69 76 65 72 73 5b 6e 64 5d 2e |cpy(drivers[nd].| 000006f0 66 69 6c 65 2c 64 72 69 76 65 72 6e 61 6d 65 29 |file,drivername)| 00000700 3b 0a 20 20 20 20 20 20 20 20 66 73 65 65 6b 28 |;. fseek(| 00000710 64 72 76 63 68 65 63 6b 2c 30 78 38 30 2c 53 45 |drvcheck,0x80,SE| 00000720 45 4b 5f 53 45 54 29 3b 0a 20 20 20 20 20 20 20 |EK_SET);. | 00000730 20 66 72 65 61 64 28 64 72 69 76 65 72 73 5b 6e | fread(drivers[n| 00000740 64 5d 2e 69 6e 66 6f 2c 31 2c 33 32 2c 64 72 76 |d].info,1,32,drv| 00000750 63 68 65 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 |check);. | 00000760 66 73 65 65 6b 28 64 72 76 63 68 65 63 6b 2c 30 |fseek(drvcheck,0| 00000770 78 63 38 2c 53 45 45 4b 5f 53 45 54 29 3b 0a 20 |xc8,SEEK_SET);. | 00000780 20 20 20 20 20 20 20 66 72 65 61 64 28 26 64 72 | fread(&dr| 00000790 69 76 65 72 73 5b 6e 64 2b 2b 5d 2e 6e 75 6d 62 |ivers[nd++].numb| 000007a0 65 72 2c 31 2c 34 2c 64 72 76 63 68 65 63 6b 29 |er,1,4,drvcheck)| 000007b0 3b 0a 20 20 20 20 20 20 20 20 66 63 6c 6f 73 65 |;. fclose| 000007c0 28 64 72 76 63 68 65 63 6b 29 3b 0a 20 20 20 20 |(drvcheck);. | 000007d0 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 0a 20 20 | }. }. | 000007e0 20 20 7d 0a 20 20 77 68 69 6c 65 28 72 2e 73 65 | }. while(r.se| 000007f0 71 5f 70 6f 69 6e 74 3e 3d 30 29 3b 0a 0a 20 20 |q_point>=0);.. | 00000800 2f 2a 20 54 65 72 6d 69 6e 61 74 65 20 6c 69 73 |/* Terminate lis| 00000810 74 20 2a 2f 0a 20 20 64 72 69 76 65 72 73 5b 6e |t */. drivers[n| 00000820 64 5d 2e 69 6e 66 6f 5b 30 5d 3d 30 3b 0a 20 20 |d].info[0]=0;. | 00000830 7d 0a 0a 76 6f 69 64 20 2a 64 72 69 76 65 72 5f |}..void *driver_| 00000840 6c 6f 61 64 28 63 68 61 72 20 2a 64 72 69 76 65 |load(char *drive| 00000850 72 6e 61 6d 65 29 0a 20 20 7b 0a 20 20 46 49 4c |rname). {. FIL| 00000860 45 20 2a 64 72 76 3b 20 6c 6f 6e 67 20 6c 65 6e |E *drv; long len| 00000870 3b 20 63 68 61 72 20 74 65 6d 70 5b 36 30 5d 3b |; char temp[60];| 00000880 0a 0a 20 20 73 70 72 69 6e 74 66 28 74 65 6d 70 |.. sprintf(temp| 00000890 2c 22 3c 53 65 72 69 61 6c 44 65 76 24 50 61 74 |,"<SerialDev$Pat| 000008a0 68 3e 4d 6f 64 75 6c 65 73 2e 25 73 2e 44 72 69 |h>Modules.%s.Dri| 000008b0 76 65 72 22 2c 64 72 69 76 65 72 6e 61 6d 65 29 |ver",drivername)| 000008c0 3b 0a 20 20 69 66 20 28 28 64 72 76 3d 66 6f 70 |;. if ((drv=fop| 000008d0 65 6e 28 74 65 6d 70 2c 22 72 62 22 29 29 3d 3d |en(temp,"rb"))==| 000008e0 4e 55 4c 4c 29 20 72 65 74 75 72 6e 28 4e 55 4c |NULL) return(NUL| 000008f0 4c 29 3b 0a 20 20 66 73 65 65 6b 28 64 72 76 2c |L);. fseek(drv,| 00000900 30 2c 53 45 45 4b 5f 45 4e 44 29 3b 0a 20 20 6c |0,SEEK_END);. l| 00000910 65 6e 3d 66 74 65 6c 6c 28 64 72 76 29 3b 0a 20 |en=ftell(drv);. | 00000920 20 66 73 65 65 6b 28 64 72 76 2c 30 2c 53 45 45 | fseek(drv,0,SEE| 00000930 4b 5f 53 45 54 29 3b 0a 20 20 66 72 65 61 64 28 |K_SET);. fread(| 00000940 64 72 69 76 65 72 5f 62 6c 6f 63 6b 2c 31 2c 6c |driver_block,1,l| 00000950 65 6e 2c 64 72 76 29 3b 0a 20 20 66 63 6c 6f 73 |en,drv);. fclos| 00000960 65 28 64 72 76 29 3b 0a 0a 20 20 2f 2a 20 4e 4f |e(drv);.. /* NO| 00000970 54 45 21 20 53 68 6f 75 6c 64 20 72 65 61 6c 6c |TE! Should reall| 00000980 79 20 63 61 6c 6c 20 69 6e 69 74 69 61 6c 69 73 |y call initialis| 00000990 65 20 65 6e 74 72 79 20 62 65 66 6f 72 65 20 63 |e entry before c| 000009a0 68 65 63 6b 69 6e 67 20 41 4e 59 20 6f 66 20 74 |hecking ANY of t| 000009b0 68 65 20 62 65 6c 6f 77 20 2a 2f 0a 20 20 64 72 |he below */. dr| 000009c0 69 76 65 72 5f 66 6c 61 67 73 3d 64 72 69 76 65 |iver_flags=drive| 000009d0 72 5f 62 6c 6f 63 6b 5b 34 39 5d 3b 0a 20 20 64 |r_block[49];. d| 000009e0 72 69 76 65 72 5f 76 65 72 73 69 6f 6e 3d 64 72 |river_version=dr| 000009f0 69 76 65 72 5f 62 6c 6f 63 6b 5b 34 38 5d 3b 0a |iver_block[48];.| 00000a00 20 20 64 72 69 76 65 72 5f 73 70 65 65 64 74 61 | driver_speedta| 00000a10 62 6c 65 3d 26 64 72 69 76 65 72 5f 62 6c 6f 63 |ble=&driver_bloc| 00000a20 6b 5b 36 34 5d 3b 0a 20 20 64 72 69 76 65 72 5f |k[64];. driver_| 00000a30 69 6e 66 6f 3d 28 63 68 61 72 2a 29 26 64 72 69 |info=(char*)&dri| 00000a40 76 65 72 5f 62 6c 6f 63 6b 5b 33 32 5d 3b 0a 20 |ver_block[32];. | 00000a50 20 64 72 69 76 65 72 5f 63 72 65 61 74 6f 72 3d | driver_creator=| 00000a60 28 63 68 61 72 2a 29 26 64 72 69 76 65 72 5f 62 |(char*)&driver_b| 00000a70 6c 6f 63 6b 5b 34 30 5d 3b 0a 0a 20 20 64 72 69 |lock[40];.. dri| 00000a80 76 65 72 5f 6e 6f 6f 66 73 70 65 65 64 73 3d 30 |ver_noofspeeds=0| 00000a90 3b 0a 20 20 77 68 69 6c 65 28 64 72 69 76 65 72 |;. while(driver| 00000aa0 5f 73 70 65 65 64 74 61 62 6c 65 5b 64 72 69 76 |_speedtable[driv| 00000ab0 65 72 5f 6e 6f 6f 66 73 70 65 65 64 73 2b 2b 5d |er_noofspeeds++]| 00000ac0 29 3b 0a 20 20 64 72 69 76 65 72 5f 6e 6f 6f 66 |);. driver_noof| 00000ad0 73 70 65 65 64 73 2d 2d 3b 0a 0a 20 20 72 65 74 |speeds--;.. ret| 00000ae0 75 72 6e 28 64 72 69 76 65 72 5f 62 6c 6f 63 6b |urn(driver_block| 00000af0 29 3b 0a 20 20 7d 0a |);. }.| 00000af7