This source file includes following definitions.
- checksum
- amiga_check_partition
1
2
3
4
5
6
7
8
9
10
11 #include <linux/fs.h>
12 #include <linux/genhd.h>
13 #include <linux/kernel.h>
14
15 #include <asm/amigardb.h>
16 #include <asm/machdep.h>
17
18 extern int current_minor;
19
20 static ulong checksum (ulong *ptr, int len)
21 {
22 ulong sum;
23 int cnt;
24
25 for (sum = 0, cnt = 0; cnt < len; cnt++)
26 sum += ptr[cnt];
27
28 return sum;
29 }
30
31
32
33
34 void amiga_check_partition(struct gendisk *hd, kdev_t dev)
35 {
36 int i, minor = current_minor, m_lim = current_minor + hd->max_p;
37 struct buffer_head *bh;
38 struct RigidDiskBlock *rdb;
39 struct PartitionBlock *pb;
40 ulong bnum, partsect;
41
42 for (bnum = 0; bnum < RDB_LOCATION_LIMIT/2; bnum++) {
43 if (!(bh = bread(dev,bnum,1024))) {
44 printk (" unable to read block %ld\n", bnum);
45 return;
46 }
47 #ifdef DEBUG
48 printk ("block read, press mousebutton to continue\n");
49 waitbut();
50 #endif
51 rdb = (struct RigidDiskBlock *)bh->b_data;
52 if (rdb->rdb_ID == IDNAME_RIGIDDISK)
53 break;
54 rdb = (struct RigidDiskBlock *)&bh->b_data[512];
55 if (rdb->rdb_ID == IDNAME_RIGIDDISK)
56 break;
57 brelse (bh);
58 }
59 if (bnum == RDB_LOCATION_LIMIT/2) {
60
61 printk (" unable to find RigidDiskBlock\n");
62 return;
63 }
64
65
66 if (checksum ((ulong *)rdb, rdb->rdb_SummedLongs) != 0) {
67 printk (" RDB checksum bad\n");
68 return;
69 }
70
71 printk(" %s%c:", hd->major_name, 'a'+(minor >> hd->minor_shift));
72
73 partsect = rdb->rdb_PartitionList;
74 brelse (bh);
75
76 for (i = 1; minor < m_lim && partsect != 0xffffffff; minor++, i++)
77 {
78 ulong *env;
79
80 if (!(bh = bread(dev,partsect/2,1024))) {
81 printk (" block %ld read failed\n", partsect);
82 return;
83 }
84 #ifdef DEBUG
85 printk ("block read, press mousebutton to continue\n");
86 waitbut();
87 #endif
88 pb = (struct PartitionBlock *)bh->b_data;
89 if (partsect & 1)
90 pb = (struct PartitionBlock *)&bh->b_data[512];
91 if (pb->pb_ID != IDNAME_PARTITION) {
92 printk (" block %ld Not a partition block (%#lx)\n",
93 partsect, pb->pb_ID);
94 brelse (bh);
95 return;
96 }
97 if (checksum ((ulong *)pb, pb->pb_SummedLongs) != 0) {
98 printk (" block %ld checksum bad\n", partsect);
99 brelse (bh);
100 return;
101 }
102
103 env = pb->pb_Environment;
104
105 hd->part[minor].start_sect = env[DE_LOWCYL]
106 * env[DE_NUMHEADS] * env[DE_BLKSPERTRACK];
107 hd->part[minor].nr_sects = (env[DE_UPPERCYL]
108 - env[DE_LOWCYL] + 1)
109 * env[DE_NUMHEADS] * env[DE_BLKSPERTRACK];
110
111 printk(" %s%c%d", hd->major_name,
112 'a'+(minor >> hd->minor_shift), i);
113
114 partsect = pb->pb_Next;
115 brelse (bh);
116 }
117
118 printk ("\n");
119 }