New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / expansion / makedosnode.c
blobfcf53b0bb98bac8ff1800c97ea2c2fc68abb9723
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: MakeDosNode() - Create a DOS DeviceNode structure.
6 Lang: English
7 */
9 #include "expansion_intern.h"
10 #include <exec/memory.h>
11 #include <dos/dos.h>
12 #include <dos/dosextens.h>
13 #include <proto/exec.h>
14 #include <string.h>
16 # define DEBUG 0
17 # include <aros/debug.h>
19 /*****************************************************************************
21 NAME */
22 #include <dos/filehandler.h>
23 #include <proto/expansion.h>
25 AROS_LH1(struct DeviceNode *, MakeDosNode,
27 /* SYNOPSIS */
28 AROS_LHA(APTR, parmPacket, A0),
30 /* LOCATION */
31 struct ExpansionBase *, ExpansionBase, 24, Expansion)
33 /* FUNCTION
34 MakeDosNode() will create a DeviceNode structure suitable for
35 passing to dos.library which contains all the information about
36 a device stored in the parmPacket array. This will allow you to
37 enter a DOS device into the system from the information contained
38 in a DosEnvec structure (such as in a RigidDiskBlock PartitionBlock
39 structure).
41 MakeDosNode() will allocate the memory that it needs to construct
42 the DeviceNode, the strings and a FileSysStartupMsg that is passed
43 to the filesystem handler on startup.
45 You can use AddBootNode() to add a node to the system.
47 INPUTS
48 parmPacket - a longword array containing the device parameters
49 required to initialize the structures. This is a
50 variable length structure. See also the DosEnvec
51 structure in dos/filehandler.h
53 longword description
54 -------- -----------
55 0 Exec string with dos handler name (eg ffs.handler)
56 1 Exec string with exec device name (eg fdsk.device)
57 2 unit number of device to open
58 3 flags (for OpenDevice())
59 4 length of the remaining data
60 5-n environment data - consists of:
62 5 Size of standard device block in 32 bit longwords
63 6 not used; 0
64 7 # of heads - drive specific
65 8 # of sectors per block - not used; 0
66 9 # of blocks per track - drive specific
67 10 # of reserved blocks at the start of the partition
68 11 # of reserved blocks at the end of the partition
69 12 device interleave
70 13 starting cylinder of partition
71 14 end cylinder of partition
72 15 initial number of buffers
73 16 type of memory for buffers (CHIP, FAST,...)
74 17 max number of bytes to transfer at one time
75 18 address mask allowable for DMA transfers
76 19 boot priority for autobootable devices
77 20 standard DOS filesystem ID (eg 'DOS\1')
78 21 baud rate for serial handler
79 22 control word for handler/filesystem
80 23 number of boot blocks on this partition
82 RESULT
83 deviceNode - An initialized DeviceNode structure, or NULL if
84 the required memory could not be allocated. The
85 caller will have to modify this structure before
86 passing it to AddBootNode().
88 NOTES
89 There are a number of fields of the DeviceNode structure that this
90 function cannot initialize due to a lack of information. You
91 should fill these in yourself.
93 EXAMPLE
95 BUGS
97 SEE ALSO
98 AddBootNode(), AddDosNode(), dos/MakeDosEntry()
100 INTERNALS
102 HISTORY
103 27-11-96 digulla automatically created from
104 expansion_lib.fd and clib/expansion_protos.h
106 *****************************************************************************/
108 AROS_LIBFUNC_INIT
109 AROS_LIBBASE_EXT_DECL(struct ExpansionBase *,ExpansionBase)
111 struct DeviceNode *dn;
112 struct FileSysStartupMsg *fssm;
113 struct DosEnvec *de;
114 STRPTR s1, s2 = 0;
115 int strLen1, strLen2;
116 int i; /* Loop variable */
118 if (parmPacket == NULL)
120 return NULL;
123 /* This is the environment structure */
124 de = (struct DosEnvec *)((ULONG *)parmPacket + 4);
126 dn = AllocMem(sizeof(struct DeviceNode), MEMF_CLEAR | MEMF_PUBLIC);
128 if (dn == NULL)
130 return NULL;
133 fssm = AllocMem(sizeof(struct FileSysStartupMsg),
134 MEMF_CLEAR | MEMF_PUBLIC);
136 if (fssm == NULL)
138 FreeMem(dn, sizeof(struct DeviceNode));
140 return NULL;
143 /* To help prevent fragmentation I will allocate both strings in the
144 same block of memory.
146 Add for each string, 1 for null-termination
147 1 for BSTR size
148 For the first string 3 for longword align
151 strLen1 = strlen((STRPTR)((ULONG *)parmPacket)[0]) + 5;
153 /* There doesn't have to exist an underlying block device */
154 if ((STRPTR)((ULONG *)parmPacket)[1] != NULL)
156 strLen2 = 2 + strlen((STRPTR)((ULONG *)parmPacket)[1]);
158 else
160 strLen2 = 2;
163 s1 = AllocVec(strLen2 + strLen1, MEMF_CLEAR | MEMF_PUBLIC);
165 if (s1 == NULL)
167 FreeMem(dn, sizeof(struct DeviceNode));
168 FreeMem(fssm, sizeof(struct FileSysStartupMsg));
170 return NULL;
173 /* We have no more allocations */
174 s2 = (STRPTR)(((ULONG)s1 + strLen1) & ~3);
176 for (i = 0; i < strLen1 - 5; i++)
178 AROS_BSTR_putchar(s1, i, ((STRPTR)((ULONG *)parmPacket)[0])[i]);
181 for (i = 0; i < strLen2 - 2; i++)
183 AROS_BSTR_putchar(s2, i, ((STRPTR)((ULONG *)parmPacket)[1])[i]);
186 AROS_BSTR_setstrlen(s1, (strLen1 - 5) > 255 ? 255 : (strLen1 - 5));
187 AROS_BSTR_setstrlen(s2, (strLen2 - 2) > 255 ? 255 : (strLen2 - 2));
189 /* Strings are done, now the FileSysStartupMsg */
190 fssm->fssm_Unit = ((ULONG *)parmPacket)[2];
191 fssm->fssm_Device = MKBADDR(s2);
192 fssm->fssm_Environ = MKBADDR(de);
193 fssm->fssm_Flags = ((ULONG *)parmPacket)[3];
195 /* FSSM is done, now the DeviceNode */
196 dn->dn_Handler = MKBADDR(s1);
197 dn->dn_Startup = MKBADDR(fssm);
198 dn->dn_Type = DLT_DEVICE;
200 /* Sorry, we can't fill in dn_NewName and dn_OldName here, we simply
201 don't have that information */
203 return dn;
205 AROS_LIBFUNC_EXIT
206 } /* MakeDosNode */