2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <dos/filehandler.h>
8 #include <exec/rawfmt.h>
9 #include <libraries/expansion.h>
10 #include <libraries/expansionbase.h>
11 #include <proto/exec.h>
12 #include <proto/expansion.h>
14 #include LC_LIBDEFS_FILE
16 extern const char GM_UNIQUENAME(LibName
)[];
18 static int Automount(struct HostDiskBase
*hdskBase
)
20 struct ExpansionBase
*ExpansionBase
= NULL
;
22 struct DriveGeometry dg
;
25 if (hdskBase
->segList
)
27 D(bug("hostdisk: Loaded from disk, skipping automount.\n"));
31 len
= strlen(hdskBase
->DiskDevice
) + 5;
32 unit
= AllocMem(len
, MEMF_ANY
);
36 for (u
= 0; u
< 30; u
++)
40 NewRawDoFmt(hdskBase
->DiskDevice
, (VOID_FUNC
)RAWFMTFUNC_STRING
, unit
, u
+ hdskBase
->unitBase
);
42 if (Host_ProbeGeometry(hdskBase
, unit
, &dg
) == 0)
44 struct DeviceNode
*devnode
;
45 TEXT dosdevname
[4] = "HD0";
49 ExpansionBase
= (struct ExpansionBase
*)OpenLibrary("expansion.library", 40);
58 dosdevname
[2] += u
% 10;
60 dosdevname
[2] = 'A' - 10 + u
;
62 D(bug("hostdisk: Automounting %s as %s\n", unit
, dosdevname
));
64 pp
[0] = (IPTR
)dosdevname
;
65 pp
[1] = (IPTR
)GM_UNIQUENAME(LibName
);
67 pp
[DE_TABLESIZE
+ 4] = DE_BOOTBLOCKS
;
68 pp
[DE_SIZEBLOCK
+ 4] = dg
.dg_SectorSize
>> 2;
69 pp
[DE_NUMHEADS
+ 4] = dg
.dg_Heads
;
70 pp
[DE_SECSPERBLOCK
+ 4] = 1;
71 pp
[DE_BLKSPERTRACK
+ 4] = dg
.dg_TrackSectors
;
72 pp
[DE_RESERVEDBLKS
+ 4] = 2;
73 pp
[DE_LOWCYL
+ 4] = 0;
74 pp
[DE_HIGHCYL
+ 4] = dg
.dg_Cylinders
- 1;
75 pp
[DE_NUMBUFFERS
+ 4] = 10;
76 pp
[DE_BUFMEMTYPE
+ 4] = MEMF_PUBLIC
;
77 pp
[DE_MAXTRANSFER
+ 4] = 0x00200000;
78 pp
[DE_MASK
+ 4] = -2; /* On Windows Host_Read() fails with ERROR_INVALID_PARAMETER on odd addresses */
79 pp
[DE_BOOTPRI
+ 4] = 0;
80 pp
[DE_DOSTYPE
+ 4] = AROS_MAKE_ID('D','O','S','\001');
81 pp
[DE_CONTROL
+ 4] = 0;
82 pp
[DE_BOOTBLOCKS
+ 4] = 2;
84 devnode
= MakeDosNode(pp
);
87 CloseLibrary(&ExpansionBase
->LibNode
);
92 AddBootNode(pp
[DE_BOOTPRI
+ 4], ADNF_STARTPROC
, devnode
, NULL
);
97 CloseLibrary(&ExpansionBase
->LibNode
);
103 ADD2INITLIB(Automount
, 20);