Init control word to zero, cdrom-handler reads this and will crash if it is non-zero...
[AROS.git] / rom / partition / openrootpartition.c
bloba1e6b9750f64d1a8601e11990a668f45ae0a7a13
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 */
7 #include <proto/exec.h>
8 #include <exec/memory.h>
10 #include "partition_intern.h"
11 #include "partition_support.h"
12 #include "platform.h"
14 /*****************************************************************************
16 NAME */
17 AROS_LH2(struct PartitionHandle *, OpenRootPartition,
19 /* SYNOPSIS */
20 AROS_LHA(CONST_STRPTR, Device, A1),
21 AROS_LHA(LONG, Unit, D1),
23 /* LOCATION */
24 struct Library *, PartitionBase, 5, Partition)
26 /* FUNCTION
27 Create a root handle by opening a trackdisk-compatible device.
29 INPUTS
30 Device - name of the block device
31 Unit - unit of the block device
33 RESULT
34 handle to the device
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 HISTORY
47 21-02-02 first version
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 struct PartitionHandle *ph;
55 ph = AllocMem(sizeof(struct PartitionHandle), MEMF_PUBLIC | MEMF_CLEAR);
56 if (ph)
58 ph->bd = AllocMem(sizeof(struct PartitionBlockDevice), MEMF_PUBLIC);
59 if (ph->bd)
61 ph->bd->cmdread = CMD_READ;
62 ph->bd->cmdwrite = CMD_WRITE;
63 ph->bd->port = CreateMsgPort();
64 if (ph->bd->port)
66 ph->bd->ioreq = (struct IOExtTD *)CreateIORequest(ph->bd->port, sizeof(struct IOExtTD));
67 if (ph->bd->ioreq)
69 if (OpenDevice(Device, Unit, (struct IORequest *)ph->bd->ioreq, 0)==0)
71 if (getGeometry(PartitionBase, ph->bd->ioreq, &ph->dg)==0)
73 if (ph->dg.dg_DeviceType != DG_CDROM)
75 ph->de.de_SizeBlock = ph->dg.dg_SectorSize>>2;
76 ph->de.de_Surfaces = ph->dg.dg_Heads;
77 ph->de.de_BlocksPerTrack = ph->dg.dg_TrackSectors;
78 ph->de.de_HighCyl = ph->dg.dg_Cylinders-1;
79 ph->de.de_BufMemType = ph->dg.dg_BufMemType;
81 /* The followin are common defaults */
82 ph->de.de_TableSize = DE_BUFMEMTYPE;
83 ph->de.de_SectorPerBlock = 1;
84 ph->de.de_NumBuffers = 20;
86 PartitionNsdCheck(PartitionBase, ph);
87 return ph;
91 DeleteIORequest((struct IORequest *)ph->bd->ioreq);
93 DeleteMsgPort(ph->bd->port);
95 FreeMem(ph->bd, sizeof(struct PartitionBlockDevice));
97 FreeMem(ph, sizeof(struct PartitionHandle));
98 ph = 0;
100 return 0;
101 AROS_LIBFUNC_EXIT