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

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

File size: 1.6 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
4 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
5 *                All Rights Reserved
6 *
7 *  This library is free software. It comes without any warranty, to
8 *  the extent permitted by applicable law. You can redistribute it
9 *  and/or modify it under the terms of the Do What The Fuck You Want
10 *  To Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "kernel.h"
15#include "klibc.h"
16#include "floppy.h"
17
18
19int floppy_get_info(struct floppy_info *floppy_info)
20{
21    outb(0x70, 0x10);
22    unsigned char c = inb(0x71);
23    int a = c >> 4;
24    int b = c & 0xF;
25
26    char *drive_type[6] = {
27        "none",
28        "360kb 5.25in",
29        "1.2mb 5.25in",
30        "720kb 3.5in",
31        "1.44mb 3.5in",
32        "2.88mb 3.5in"
33    };
34
35
36    memcpy(floppy_info->drive[0].type, drive_type[a],
37           strlen(drive_type[a]) + 1);
38    memcpy(floppy_info->drive[1].type, drive_type[b],
39           strlen(drive_type[b]) + 1);
40
41    floppy_info->count = 0;
42    if (a != 0)
43        floppy_info->count++;
44    if (b != 0)
45        floppy_info->count++;
46
47    return 0;
48}
49
50void floppy_print_info(struct floppy_info *floppy_info)
51{
52    printf("%d floppy drive(s)\n", floppy_info->count);
53    if (floppy_info->count)
54    {
55        printf("Floppy %d type %s\n", 0, floppy_info->drive[0].type);
56        if (floppy_info->count == 2)
57        {
58            printf("Floppy %d type %s\n", 1, floppy_info->drive[1].type);
59        }
60    }
61
62}
63
64int floppy_get_status(void)
65{
66    unsigned char c = inb(0x1F7);
67    return c;
68}
Note: See TracBrowser for help on using the repository browser.