Bladeren bron

BIOS floppy handling code moved to where it will really live.

tags/v0.9.3
Michael Brown 19 jaren geleden
bovenliggende
commit
fcee25024f
3 gewijzigde bestanden met toevoegingen van 92 en 79 verwijderingen
  1. 19
    79
      src/arch/i386/drivers/disk/floppy.c
  2. 68
    0
      src/arch/i386/include/bios_disks.h
  3. 5
    0
      src/include/disk.h

+ 19
- 79
src/arch/i386/drivers/disk/floppy.c Bestand weergeven

@@ -1,88 +1,28 @@
1
-#if	(TRY_FLOPPY_FIRST > 0)
1
+#include "console.h"
2
+#include "disk.h"
3
+#include "bios_disks.h"
2 4
 
3
-/*
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2, or (at
7
- * your option) any later version.
8
- */
9
-
10
-#include "etherboot.h"
11
-
12
-#define BOOTSECT ((char *)0x7C00)
13
-#define BOOTSIG  ((unsigned short *)BOOTSECT)[0xFF]
14
-#define PARTTAB  ((partentry *)(BOOTSECT+0x1BE))
5
+static void fill_floppy_name ( char *buf, uint8_t drive ) {
6
+	sprintf ( buf, "fd%d", drive );
7
+}
15 8
 
16
-typedef struct partentry {
17
-	unsigned char flags;
18
-	unsigned char start_head;
19
-	unsigned char start_sector;
20
-	unsigned char start_cylinder;
21
-	unsigned char type;
22
-	unsigned char end_head;
23
-	unsigned char end_sector;
24
-	unsigned char end_cylinder;
25
-	unsigned long offset;
26
-	unsigned long length;
27
-} partentry;
9
+static struct disk_operations floppy_operations = {
28 10
 
29
-static unsigned int disk_read_retry(int dev,int c,int h,int s)
30
-{
31
-	int retry = 3,rc;
11
+};
32 12
 
33
-	while (retry-- && (rc = pcbios_disk_read(dev,c,h,s,BOOTSECT)) != 0);
34
-	if (BOOTSIG != 0xAA55) {
35
-		printf("not a boot sector");
36
-		return(0xFFFF); }
37
-	return(rc);
13
+static int floppy_probe ( struct disk *disk,
14
+			  struct bios_disk_device *bios_disk ) {
15
+	
16
+	return 1;
38 17
 }
39 18
 
40
-int bootdisk(int dev,int part)
41
-{
42
-	int rc;
43
-
44
-	disk_init();
45
-	if ((rc = disk_read_retry(dev,0,0,1)) != 0) {
46
-	readerr:
47
-		if (rc != 0xFFFF)
48
-			printf("read error (%#hhX)",rc/256);
49
-		return(0); }
50
-	if (part) {
51
-		partentry *ptr;
52
-
53
-		if (part >= 5) {
54
-			int i;
55
-			for (i = 0, ptr = PARTTAB; ptr->type != 5; ptr++)
56
-				if (++i == 4) {
57
-					printf("partition not found");
58
-					return(0); }
59
-			if ((rc = disk_read_retry(dev,
60
-						  ptr->start_cylinder,
61
-						  ptr->start_head,
62
-						  ptr->start_sector)) != 0)
63
-				goto readerr;
64
-			part -= 4; }
65
-		if (!(ptr = PARTTAB-1+part)->type) {
66
-			printf("empty partition");
67
-			return(0); }
68
-		if ((rc = disk_read_retry(dev,
69
-					  ptr->start_cylinder,
70
-					  ptr->start_head,
71
-					  ptr->start_sector)) != 0)
72
-			goto readerr; }
73
-	cleanup();
74
-	gateA20_unset();
75
-	/* Set %edx to device number to emulate BIOS
76
-	   Fortunately %edx is not used after this */
77
-	__asm__("movl %0,%%edx" : : "g" (dev));
78
-	xstart((unsigned long)BOOTSECT, 0, 0);
79
-	return(0);
19
+static void floppy_disable ( struct disk *disk,
20
+			     struct bios_disk_device *bios_disk ) {
21
+	
80 22
 }
81 23
 
82
-#endif
24
+static struct bios_disk_driver floppy_driver =
25
+	BIOS_DISK_DRIVER ( fill_floppy_name, 0x00, 0x7f );
83 26
 
84
-/*
85
- * Local variables:
86
- *  c-basic-offset: 8
87
- * End:
88
- */
27
+DRIVER ( "floppy", disk_driver, bios_disk_driver, floppy_driver,
28
+	 floppy_probe, floppy_disable );

+ 68
- 0
src/arch/i386/include/bios_disks.h Bestand weergeven

@@ -0,0 +1,68 @@
1
+#ifndef BIOS_DISKS_H
2
+#define BIOS_DISKS_H
3
+
4
+#include "dev.h"
5
+
6
+/*
7
+ * Constants
8
+ *
9
+ */
10
+
11
+#define	BIOS_DISK_MAX_NAME_LEN	6
12
+
13
+struct bios_disk_sector {
14
+	char data[512];
15
+};
16
+
17
+/*
18
+ * The location of a BIOS disk
19
+ *
20
+ */
21
+struct bios_disk_loc {
22
+	uint8_t drive;
23
+};
24
+
25
+/*
26
+ * A physical BIOS disk device
27
+ *
28
+ */
29
+struct bios_disk_device {
30
+	char name[BIOS_DISK_MAX_NAME_LEN];
31
+	uint8_t drive;
32
+	uint8_t type;
33
+};
34
+
35
+/*
36
+ * A BIOS disk driver, with a valid device ID range and naming
37
+ * function.
38
+ *
39
+ */
40
+struct bios_disk_driver {
41
+	void ( *fill_drive_name ) ( char *buf, uint8_t drive );
42
+	uint8_t min_drive;
43
+	uint8_t max_drive;
44
+};
45
+
46
+/*
47
+ * Define a BIOS disk driver
48
+ *
49
+ */
50
+#define BIOS_DISK_DRIVER( _fill_drive_name, _min_drive, _max_drive ) {	      \
51
+	.fill_drive_name = _fill_drive_name,				      \
52
+	.min_drive = _min_drive,					      \
53
+	.max_drive = _max_drive,					      \
54
+}
55
+
56
+/*
57
+ * Functions in bios_disks.c
58
+ *
59
+ */
60
+
61
+
62
+/*
63
+ * bios_disk bus global definition
64
+ *
65
+ */
66
+extern struct bus_driver bios_disk_driver;
67
+
68
+#endif /* BIOS_DISKS_H */

+ 5
- 0
src/include/disk.h Bestand weergeven

@@ -1,6 +1,7 @@
1 1
 #ifndef DISK_H
2 2
 #define DISK_H
3 3
 
4
+#include "etherboot.h" /* for sector_t */
4 5
 #include "dev.h"
5 6
 
6 7
 /*
@@ -30,6 +31,9 @@ struct disk
30 31
 	int           direction;
31 32
 };
32 33
 
34
+struct disk_operations {
35
+};
36
+
33 37
 extern struct disk disk;
34 38
 extern int url_file(const char *name,
35 39
 	int (*fnc)(unsigned char *, unsigned int, unsigned int, int));
@@ -39,6 +43,7 @@ extern int disk_load_configuration(struct dev *dev);
39 43
 extern int disk_load(struct dev *dev);
40 44
 extern void disk_disable(void);
41 45
 
46
+extern struct type_driver disk_driver;
42 47
 
43 48
 #ifndef DOWNLOAD_PROTO_DISK
44 49
 #define disk_disable()	do { } while(0)

Laden…
Annuleren
Opslaan