2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
8 #include <exec/memory.h>
10 #include "partition_intern.h"
11 #include "partition_support.h"
14 /*****************************************************************************
17 AROS_LH2(struct PartitionHandle
*, OpenRootPartition
,
20 AROS_LHA(CONST_STRPTR
, Device
, A1
),
21 AROS_LHA(LONG
, Unit
, D1
),
24 struct Library
*, PartitionBase
, 5, Partition
)
27 Create a root handle by opening a trackdisk-compatible device.
30 Device - name of the block device
31 Unit - unit of the block device
47 21-02-02 first version
49 *****************************************************************************/
53 struct PartitionHandle
*ph
;
58 ph
= AllocMem(sizeof(struct PartitionHandle
), MEMF_PUBLIC
| MEMF_CLEAR
);
61 ph
->bd
= AllocMem(sizeof(struct PartitionBlockDevice
), MEMF_PUBLIC
);
64 ph
->bd
->cmdread
= CMD_READ
;
65 ph
->bd
->cmdwrite
= CMD_WRITE
;
66 ph
->bd
->port
= CreateMsgPort();
69 ph
->bd
->ioreq
= (struct IOExtTD
*)CreateIORequest(ph
->bd
->port
, sizeof(struct IOExtTD
));
72 if (OpenDevice(Device
, Unit
, (struct IORequest
*)ph
->bd
->ioreq
, 0)==0)
74 if (getGeometry(PartitionBase
, ph
->bd
->ioreq
, &ph
->dg
)==0)
76 if (ph
->dg
.dg_DeviceType
!= DG_CDROM
)
78 ph
->de
.de_SizeBlock
= ph
->dg
.dg_SectorSize
>>2;
79 ph
->de
.de_Surfaces
= ph
->dg
.dg_Heads
;
80 ph
->de
.de_BlocksPerTrack
= ph
->dg
.dg_TrackSectors
;
81 ph
->de
.de_HighCyl
= ph
->dg
.dg_Cylinders
-1;
82 ph
->de
.de_BufMemType
= ph
->dg
.dg_BufMemType
;
84 /* The followin are common defaults */
85 ph
->de
.de_TableSize
= DE_BUFMEMTYPE
;
86 ph
->de
.de_SectorPerBlock
= 1;
87 ph
->de
.de_NumBuffers
= 20;
89 PartitionNsdCheck(PartitionBase
, ph
);
94 DeleteIORequest((struct IORequest
*)ph
->bd
->ioreq
);
96 DeleteMsgPort(ph
->bd
->port
);
98 FreeMem(ph
->bd
, sizeof(struct PartitionBlockDevice
));
100 FreeMem(ph
, sizeof(struct PartitionHandle
));