1 /*
2  * The ARAnyM BetaDOS driver.
3  *
4  * 2001/2002 STan
5  *
6  * Based on:
7  * @(#)cookiefs/dosmain.c
8  *
9  * Copyright (c) Julian F. Reschke, 28. November 1995
10  * All rights reserved.
11  *
12  **/
13 
14 #include <mintbind.h>
15 #include <mint/basepage.h>
16 #include <stdlib.h>
17 #include <string.h>
18 
19 #include "mintfake.h"
20 
21 
22 #define DEVNAME "DEV.DOS Filesystem"
23 #define VERSION "0.1"
24 
25 #if 0
26 #include "nfd.h"
27 #define TRACE(x) NFD(x)
28 #define DEBUG(x) NFD(x)
29 #else
30 #define TRACE(x)
31 #define DEBUG(x)
32 #endif
33 
34 
35 char DriverName[] = DEVNAME" "VERSION;
36 long ldp;
37 
38 
39 void __CDECL ShowBanner( void );
40 void* __CDECL InitDevice( long bosDevID, long dosDevID );
41 unsigned long get_cookie (unsigned long tag);
42 
43 /* Diverse Utility-Funktionen */
44 
Bconws(char * str)45 static int Bconws( char *str )
46 {
47     int cnt = 0;
48 
49     while (*str) {
50         cnt++;
51         if (*str == '\n') {
52             Bconout (2, '\r');
53             cnt++;
54         }
55         Bconout (2, *str++);
56     }
57 
58     return cnt;
59 }
60 
ShowBanner(void)61 void __CDECL ShowBanner( void )
62 {
63     Bconws (
64             "\n\033p "DEVNAME" "VERSION" \033q "
65             "\nCopyright (c) ARAnyM Development Team, "__DATE__"\n"
66             );
67 }
68 
69 struct cookie
70 {
71 	long tag;
72 	long value;
73 };
74 
get_cookie(unsigned long tag)75 unsigned long get_cookie (unsigned long tag)
76 {
77 	struct cookie *cookie = *(struct cookie **)0x5a0;
78 	if (!cookie) return 0;
79 
80 	while (cookie->tag) {
81 		if (cookie->tag == tag) return cookie->value;
82 		cookie++;
83 	}
84 
85 	return 0;
86 }
87 
88 /* FIXME: from bosmeta.c */
89 int bosfs_initialize();
90 
InitDevice(long bosDevID,long dosDevID)91 void* __CDECL InitDevice( long bosDevID, long dosDevID )
92 {
93 	if (get_cookie(0x4D694E54L /*'MiNT'*/))
94 	{
95 		return (void*)-1;
96 	}
97 
98 	/*
99 	 * We _must_ use the bosDevID to define the drive letter here
100 	 * because MetaDOS (in contrary to BetaDOS) does not provide
101 	 * the dosDevID
102 	 */
103 	DEBUG(("InitDevice: [dosDev=%ld, bosDev=%ld]", dosDevID, bosDevID ));
104 
105 	if ( bosfs_initialize() < 0 )
106 	{
107 		return (void*)-1;
108 	}
109 
110 	return &ldp;
111 }
112 
113