Root/
Source at commit 1406 created 12 years 10 months ago. By meklort, Revert drivers.c so that kexts are only loaded when OSBundleRequired is set and that value is not safe mode. Added some comments about it too. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 2011 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | #include <stdio.h>␊ |
6 | ␊ |
7 | #include <IOKit/IOTypes.h>␊ |
8 | #include <BiosDisk.hpp>␊ |
9 | #include <GUIDPartition.hpp>␊ |
10 | #include <FDiskPartition.hpp>␊ |
11 | ␊ |
12 | #define MAXDEV 32␊ |
13 | #define BIOSBUFFER 512 * 8 /* 4Kb */␊ |
14 | extern "C"␊ |
15 | {␊ |
16 | void Disk_start();␊ |
17 | }␊ |
18 | ␊ |
19 | ␊ |
20 | Disk*␉␉disks[MAXDEV];␊ |
21 | UInt8 numBiosDisks = 0;␊ |
22 | UInt8* diskBuffer = NULL;␊ |
23 | ␊ |
24 | void DetermineDisks();␊ |
25 | ␊ |
26 | void Disk_start()␊ |
27 | {␊ |
28 | //diskBuffer = (UInt8*)malloc(BIOSBUFFER);␊ |
29 | /*UInt8* mbr = (UInt8*)malloc(512);␊ |
30 | ␊ |
31 | disk->Read(0, 1, mbr);␊ |
32 | printf("mbr[0] = 0x%X\n", mbr[0]);␊ |
33 | ␊ |
34 | printf("mbr[510] = 0x%X\n", mbr[510]);␊ |
35 | printf("mbr[511] = 0x%X\n", mbr[511]);␊ |
36 | ␊ |
37 | ␊ |
38 | GUIDPartition* partition = new GUIDPartition(disk, 0);␊ |
39 | if(partition->probe())␊ |
40 | {␊ |
41 | partition->Read(0, 1, mbr);␊ |
42 | printf("GUID[0]/[0] = 0x%X\n", mbr[0]);␊ |
43 | ␊ |
44 | }␊ |
45 | } ␊ |
46 | */␊ |
47 | DetermineDisks();␊ |
48 | ␊ |
49 | printf("This is a simple BootDisk_start test.\n");␊ |
50 | ␊ |
51 | ␊ |
52 | ␊ |
53 | while (1);␊ |
54 | }␊ |
55 | ␊ |
56 | void DetermineDisks()␊ |
57 | {␊ |
58 | /*char diskName[] = "bios:/hd%s/";␊ |
59 | ␊ |
60 | for(int i = 0; i < MAXBIOSDEV; i++)␊ |
61 | {␊ |
62 | sprintf(diskName, "bios:/hd%d/", i);␊ |
63 | BiosDisk* disk = new BiosDisk(diskName);␊ |
64 | if(disk->probe())␊ |
65 | {␊ |
66 | printf("Disk %s exists\n", diskName);␊ |
67 | disks[numBiosDisks++] = disk;␊ |
68 | ␊ |
69 | ␊ |
70 | // Check if the disk is GUID␊ |
71 | GUIDPartition* partition = new GUIDPartition(disk, 0);␊ |
72 | UInt8 partitions = partition->getNumPartitions();␊ |
73 | printf("GUID Disk w/ %d disks\n", partitions);␊ |
74 | ␊ |
75 | for(UInt8 partno = 0; partno < partitions; partno++)␊ |
76 | {␊ |
77 | GUIDPartition* partition = new GUIDPartition(disk, partno);␊ |
78 | if(partition->probe())␊ |
79 | {␊ |
80 | printf("Partition %d valid\n", partno);␊ |
81 | }␊ |
82 | }␊ |
83 | ␊ |
84 | ␊ |
85 | // If not, check if the disk is MBR␊ |
86 | FDiskPartition* mbrdisk = new FDiskPartition(disk, 0);␊ |
87 | partitions = mbrdisk->getNumPartitions();␊ |
88 | printf("MBR Disk w/ %d disks\n", partitions);␊ |
89 | ␊ |
90 | ␊ |
91 | }␊ |
92 | else␊ |
93 | {␊ |
94 | delete disk;␊ |
95 | }␊ |
96 | ␊ |
97 | }␊ |
98 | ␉ */␊ |
99 | }␊ |
100 |