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

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