OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [scsi/] [sd_ioctl.c] - Blame information for rev 1626

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*
2
 * drivers/scsi/sd_ioctl.c
3
 *
4
 * ioctl handling for SCSI disks
5
 */
6
 
7
#include <linux/kernel.h>
8
#include <linux/sched.h>
9
#include <linux/mm.h>
10
#include <linux/fs.h>
11
#include <linux/hdreg.h>
12
#include <linux/errno.h>
13
 
14
#include <asm/segment.h>
15
 
16
#include <linux/blk.h>
17
#include "scsi.h"
18
#include <scsi/scsi_ioctl.h>
19
#include "hosts.h"
20
#include "sd.h"
21
#include <scsi/scsicam.h>     /* must follow "hosts.h" */
22
 
23
int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
24
{
25
    kdev_t dev = inode->i_rdev;
26
    int error;
27
    struct Scsi_Host * host;
28
    int diskinfo[4];
29
    struct hd_geometry *loc = (struct hd_geometry *) arg;
30
 
31
    switch (cmd) {
32
    case HDIO_GETGEO:   /* Return BIOS disk parameters */
33
        if (!loc)  return -EINVAL;
34
        error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
35
        if (error)
36
            return error;
37
        host = rscsi_disks[MINOR(dev) >> 4].device->host;
38
 
39
/* default to most commonly used values */
40
 
41
        diskinfo[0] = 0x40;
42
        diskinfo[1] = 0x20;
43
        diskinfo[2] = rscsi_disks[MINOR(dev) >> 4].capacity >> 11;
44
 
45
/* override with calculated, extended default, or driver values */
46
 
47
        if(host->hostt->bios_param != NULL)
48
            host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
49
                                    dev,
50
                                    &diskinfo[0]);
51
        else scsicam_bios_param(&rscsi_disks[MINOR(dev) >> 4],
52
                                dev, &diskinfo[0]);
53
 
54
        put_user(diskinfo[0], &loc->heads);
55
        put_user(diskinfo[1], &loc->sectors);
56
        put_user(diskinfo[2], &loc->cylinders);
57
        put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
58
        return 0;
59
    case BLKGETSIZE:   /* Return device size */
60
        if (!arg)  return -EINVAL;
61
        error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
62
        if (error)
63
            return error;
64
        put_user(sd[MINOR(inode->i_rdev)].nr_sects,
65
                 (long *) arg);
66
        return 0;
67
 
68
    case BLKRASET:
69
        if (!suser())
70
                return -EACCES;
71
        if(!(inode->i_rdev)) return -EINVAL;
72
        if(arg > 0xff) return -EINVAL;
73
        read_ahead[MAJOR(inode->i_rdev)] = arg;
74
        return 0;
75
 
76
    case BLKRAGET:
77
        if (!arg)
78
                return -EINVAL;
79
        error = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
80
        if (error)
81
            return error;
82
        put_user(read_ahead[MAJOR(inode->i_rdev)], (int *) arg);
83
        return 0;
84
 
85
    case BLKFLSBUF:
86
        if(!suser())  return -EACCES;
87
        if(!(inode->i_rdev)) return -EINVAL;
88
        fsync_dev(inode->i_rdev);
89
        invalidate_buffers(inode->i_rdev);
90
        return 0;
91
 
92
    case BLKRRPART: /* Re-read partition tables */
93
        return revalidate_scsidisk(dev, 1);
94
 
95
    RO_IOCTLS(dev, arg);
96
 
97
    default:
98
        return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
99
    }
100
}
101
 
102
/*
103
 * Overrides for Emacs so that we follow Linus's tabbing style.
104
 * Emacs will notice this stuff at the end of the file and automatically
105
 * adjust the settings for this buffer only.  This must remain at the end
106
 * of the file.
107
 * ---------------------------------------------------------------------------
108
 * Local variables:
109
 * c-indent-level: 4
110
 * c-brace-imaginary-offset: 0
111
 * c-brace-offset: -4
112
 * c-argdecl-indent: 4
113
 * c-label-offset: -4
114
 * c-continued-statement-offset: 4
115
 * c-continued-brace-offset: 0
116
 * indent-tabs-mode: nil
117
 * tab-width: 8
118
 * End:
119
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.