1 |
|
---|
2 | // ù Ä ÄÄÄÄÍÍ = Ä ù Ä = ÍÍÄÄÄÄ Ä ù
|
---|
3 | // ³ ³
|
---|
4 | // ÜÛÛÛÛÛÛÛÜ ÜÛÜ ÜÛÛÛÛÛÛÛÛÜ ú úÄÄÄÍÄÄÍÄÍÍÄÄÍÍÍÍÄÍÍÍÍÍÍÍÍÍÎÄ
|
---|
5 | // ³ ÛÛÛÛßßßÛÛÛÛ ÛÛÛÛÛ ÛÛÛß ßÛÛÛ ³ AiR-BOOT - Installer/2 º
|
---|
6 | // º ÛÛÛÛÜÜÜÛÛÛÛ ÛÛÛÛÛ ÛÛÛÜ ÜÛÛÛ º ú ÄÄÄÄÍÄÍÍÄÄÍÍÍÍÄÍÍÍÍÍÍÍÍÄÍÍÍÍÍÎÄ
|
---|
7 | // º ÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛß º Section: AiR-BOOTUP Package º
|
---|
8 | // º ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛ ßÛÛÛÛÜ º ³ Created: 24/10/02 º
|
---|
9 | // ³ ßÛÛß ßÛÛß ßÛß ßÛÛß ßÛÛß ³ ³ Last Modified: ³
|
---|
10 | // ÜÜÜ ³ Number Of Modifications: 000 ³
|
---|
11 | // ù ÜÛÛß ù ³ INCs required: *none* ³
|
---|
12 | // ÄÄÄÄÄÄÄ ÜÛÛß º Written By: Martin Kiewitz ³
|
---|
13 | // ³ Ú¿Ú¿³ÜÛÛÛÜÜÛÛÛÜ ³ º (c) Copyright by ³
|
---|
14 | // º ÀÙ³ÀÙßÛÛÛßßÜÛÛß º º AiR ON-Line Software '02 ú
|
---|
15 | // º ÄÄÄÄÄÄÄ ÜÛÛÝ º º All rights reserved.
|
---|
16 | // º ÜÛÛÛÄÄÄÄÄÄÄÄÄ º ÄÎÍÍÍÄÍÍÍÍÍÄÍÍÍÍÄÍÍÄÄÍÄÄÍÄÄÄúÄÄ ú
|
---|
17 | // º ÜÛÛÛݳ ³Ú¿³³Ä º
|
---|
18 | // ³ ÜÛÛÛÛ Àij³ÀÙ³Ä ³
|
---|
19 | // ßÛÛÛÛÝÄÄÄÄÄÄÄÄÄÄ
|
---|
20 | // ³ ßß ³
|
---|
21 | // ù ÄŽ-=iç éï-Liïî SéâWçî=-ÃÄÄ ù
|
---|
22 |
|
---|
23 | #define INCL_NOPMAPI
|
---|
24 | #define INCL_DOS
|
---|
25 | #define INCL_DOSDEVIOCTL
|
---|
26 | #include <os2.h>
|
---|
27 | #include <malloc.h>
|
---|
28 |
|
---|
29 | #include <global.h>
|
---|
30 |
|
---|
31 | USHORT PHYS_EnumeratePhysicalDisks (void) {
|
---|
32 | USHORT NumDrives = 0;
|
---|
33 |
|
---|
34 | if (DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, &NumDrives, sizeof(NumDrives),NULL, 0) != 0)
|
---|
35 | return 0;
|
---|
36 | return NumDrives;
|
---|
37 | }
|
---|
38 |
|
---|
39 | USHORT PHYS_GetIOCTLHandle (PSZ DriveID) {
|
---|
40 | USHORT IOCTLHandle = 0;
|
---|
41 |
|
---|
42 | if (DosPhysicalDisk(INFO_GETIOCTLHANDLE, &IOCTLHandle, sizeof(IOCTLHandle),DriveID, 3) != 0)
|
---|
43 | return 0;
|
---|
44 | return IOCTLHandle;
|
---|
45 | }
|
---|
46 |
|
---|
47 | VOID PHYS_FreeIOCTLHandle (USHORT IOCTLHandle) {
|
---|
48 | DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, &IOCTLHandle, sizeof(IOCTLHandle));
|
---|
49 | return;
|
---|
50 | }
|
---|
51 |
|
---|
52 | BOOL PHYS_ReadPhysicalSector (USHORT IOCTLHandle, UCHAR Cylinder, UCHAR Head, UCHAR SectorCount, PBYTE BufferPtr) {
|
---|
53 | ULONG TrackLayoutLen = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SectorCount-1);
|
---|
54 | TRACKLAYOUT *TrackLayoutPtr = malloc(TrackLayoutLen);
|
---|
55 | ULONG cbParms = sizeof(TrackLayoutPtr);
|
---|
56 | ULONG cbData = 512;
|
---|
57 | INT i;
|
---|
58 |
|
---|
59 | TrackLayoutPtr->bCommand = 0x01;
|
---|
60 | TrackLayoutPtr->usHead = Head;
|
---|
61 | TrackLayoutPtr->usCylinder = Cylinder;
|
---|
62 | TrackLayoutPtr->usFirstSector = 0;
|
---|
63 | TrackLayoutPtr->cSectors = SectorCount;
|
---|
64 |
|
---|
65 | for (i=0; i<SectorCount; i++) {
|
---|
66 | TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
|
---|
67 | TrackLayoutPtr->TrackTable[i].usSectorSize = 512;
|
---|
68 | }
|
---|
69 |
|
---|
70 | i = 1;
|
---|
71 | if (DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_READPHYSTRACK,
|
---|
72 | TrackLayoutPtr, cbParms, &cbParms, BufferPtr, cbData, &cbData))
|
---|
73 | i = 0;
|
---|
74 | free (TrackLayoutPtr);
|
---|
75 | return i;
|
---|
76 | }
|
---|
77 |
|
---|
78 | BOOL PHYS_WritePhysicalSector (USHORT IOCTLHandle, UCHAR Cylinder, UCHAR Head, UCHAR SectorCount, PBYTE BufferPtr) {
|
---|
79 | ULONG TrackLayoutLen = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SectorCount-1);
|
---|
80 | TRACKLAYOUT *TrackLayoutPtr = malloc(TrackLayoutLen);
|
---|
81 | ULONG cbParms = sizeof(TrackLayoutPtr);
|
---|
82 | ULONG cbData = 512;
|
---|
83 | INT i;
|
---|
84 |
|
---|
85 | TrackLayoutPtr->bCommand = 0x01;
|
---|
86 | TrackLayoutPtr->usHead = Head;
|
---|
87 | TrackLayoutPtr->usCylinder = Cylinder;
|
---|
88 | TrackLayoutPtr->usFirstSector = 0;
|
---|
89 | TrackLayoutPtr->cSectors = SectorCount;
|
---|
90 |
|
---|
91 | for (i=0; i<SectorCount; i++) {
|
---|
92 | TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
|
---|
93 | TrackLayoutPtr->TrackTable[i].usSectorSize = 512;
|
---|
94 | }
|
---|
95 |
|
---|
96 | i = 1;
|
---|
97 | if (DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_WRITEPHYSTRACK,
|
---|
98 | TrackLayoutPtr, cbParms, &cbParms, BufferPtr, cbData, &cbData))
|
---|
99 | i = 0;
|
---|
100 | free (TrackLayoutPtr);
|
---|
101 | return i;
|
---|
102 | }
|
---|
103 |
|
---|
104 | USHORT PHYS_GetGeometrySectorsPerTrack (USHORT IOCTLHandle) {
|
---|
105 | DEVICEPARAMETERBLOCK DeviceParmBlock;
|
---|
106 | ULONG ulDataLength;
|
---|
107 |
|
---|
108 | if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_GETPHYSDEVICEPARAMS,
|
---|
109 | NULL, 0, NULL, &DeviceParmBlock, sizeof(DeviceParmBlock), &ulDataLength))
|
---|
110 | return DeviceParmBlock.cSectorsPerTrack;
|
---|
111 | return 0;
|
---|
112 | }
|
---|
113 |
|
---|
114 | USHORT PHYS_GetGeometryHeadsPerCylinder (USHORT IOCTLHandle) {
|
---|
115 | DEVICEPARAMETERBLOCK DeviceParmBlock;
|
---|
116 | ULONG ulDataLength;
|
---|
117 |
|
---|
118 | if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_GETPHYSDEVICEPARAMS,
|
---|
119 | NULL, 0, NULL, &DeviceParmBlock, sizeof(DeviceParmBlock), &ulDataLength))
|
---|
120 | return DeviceParmBlock.cHeads;
|
---|
121 | return 0;
|
---|
122 | }
|
---|