source: libcaca/trunk/kernel/drivers/floppy.c @ 4154

Last change on this file since 4154 was 4154, checked in by Jean-Yves Lamoureux, 10 years ago
  • Total kernel rewrite
File size: 1.1 KB
Line 
1
2#include "kernel.h"
3#include "klibc.h"
4#include "floppy.h"
5
6
7int floppy_get_info(struct floppy_info *floppy_info)
8{
9    outb(0x70, 0x10);
10    unsigned char c = inb(0x71);
11    int a = c >> 4;
12    int b = c & 0xF;
13
14    char *drive_type[6] = {
15        "none",
16        "360kb 5.25in",
17        "1.2mb 5.25in",
18        "720kb 3.5in",
19        "1.44mb 3.5in",
20        "2.88mb 3.5in"
21    };
22
23   
24    memcpy(floppy_info->drive[0].type, drive_type[a],
25           strlen(drive_type[a]) + 1);
26    memcpy(floppy_info->drive[1].type, drive_type[b],
27           strlen(drive_type[b]) + 1);
28
29    floppy_info->count = 0;
30    if (a != 0)
31        floppy_info->count++;
32    if (b != 0)
33        floppy_info->count++;
34
35    return 0;
36}
37
38void floppy_print_info(struct floppy_info *floppy_info)
39{
40    printf("%d floppy drive(s)\n", floppy_info->count);
41    if (floppy_info->count)
42    {
43        printf("Floppy %d type %s\n", 0, floppy_info->drive[0].type);
44        if (floppy_info->count == 2)
45        {
46            printf("Floppy %d type %s\n", 1, floppy_info->drive[1].type);
47        }
48    }
49
50}
51
52int floppy_get_status(void)
53{
54    unsigned char c = inb(0x1F7);
55    return c;
56}
Note: See TracBrowser for help on using the repository browser.