The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386ipsc/md.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * Copyright 1988, 1989, 1990, 1991 by Intel Corporation,
   28  * Santa Clara, California.
   29  * 
   30  *                          All Rights Reserved
   31  * 
   32  * Permission to use, copy, modify, and distribute this software and its
   33  * documentation for any purpose and without fee is hereby granted,
   34  * provided that the above copyright notice appears in all copies and that
   35  * both the copyright notice and this permission notice appear in
   36  * supporting documentation, and that the name of Intel not be used in
   37  * advertising or publicity pertaining to distribution of the software
   38  * without specific, written prior permission.
   39  * 
   40  * INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
   41  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
   42  * SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
   43  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
   44  * PROFITS, WHETHER IN ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS
   45  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
   46  * THIS SOFTWARE.
   47  */
   48 /*
   49  * HISTORY
   50  * $Log:        md.c,v $
   51  * Revision 2.4  93/01/14  17:32:08  danner
   52  *      Proper spl typing.
   53  *      [92/12/10  17:54:13  af]
   54  * 
   55  * Revision 2.3  92/02/23  22:43:18  elf
   56  *      Added md_get_status().
   57  *      [92/02/22  19:56:15  af]
   58  * 
   59  * Revision 2.2  91/12/10  16:29:59  jsb
   60  *      New files from Intel
   61  *      [91/12/10  16:11:01  jsb]
   62  * 
   63  */ 
   64 /*
   65  * from prp, SSD Intel
   66  */
   67  
   68 #ifdef  MACH_KERNEL
   69 
   70 #include <sys/types.h>
   71 #include <vm/vm_kern.h>
   72 #include <device/buf.h>
   73 #include <device/errno.h>
   74 
   75 #include <md.h>
   76 
   77 #define READ_ONLY 0
   78 #define SECSIZE 512
   79 
   80 unsigned char *md_address;
   81 unsigned long md_size = 0;
   82 
   83 #define DEBUG   0
   84 #define dprintf if (DEBUG) printf
   85 
   86 int mdstrategy();
   87 
   88 mdopen(dev, flags)
   89 int dev;
   90 int flags;
   91 {
   92         unsigned char n;
   93         int     errcode = 0;
   94         char    c;
   95 
   96         dprintf("mdopen md address 0x%08X size 0x%08X\n", md_address, md_size);
   97         if (md_size == 0)
   98                 errcode = ENXIO;
   99         return(errcode);
  100 }
  101 
  102 
  103 mdclose(dev)
  104 {
  105 
  106         dprintf("mdclose\n");
  107         return;
  108 }
  109 
  110 
  111 /*
  112  *      No need to limit IO size to 4096 bytes.
  113  */
  114 mdread(dev, ior)
  115 dev_t           dev;
  116 io_req_t        ior;
  117 {
  118         dprintf("mdread\n");
  119         return(block_io(mdstrategy, minphys, ior));
  120 }
  121 
  122 mdwrite(dev, ior)
  123 dev_t           dev;
  124 io_req_t        ior;
  125 {
  126         dprintf("mdwrite\n");
  127         return(block_io(mdstrategy, minphys, ior));
  128 }
  129 
  130 
  131 mdstrategy(bp)
  132 struct  buf     *bp;
  133 {
  134         struct  buf     *ptr;
  135         spl_t old_priority;
  136         unsigned int blkaddr;
  137 
  138         dprintf("mdstrategy %c blk %d len %d buf 0x%08X\n",
  139                 (bp->b_flags & B_READ)? 'R' : 'W',
  140                 bp->b_blkno, bp->b_bcount, bp->b_un.b_addr);
  141 
  142         if (bp->b_bcount == 0) {
  143                 biodone(bp);
  144                 return;
  145         }
  146 
  147         if ( !(bp->b_flags & B_READ) &&
  148              (READ_ONLY)
  149            )
  150         {
  151                 bp->b_flags = B_ERROR;
  152                 bp->b_error = ENXIO;
  153                 biodone(bp);
  154                 return;
  155         }
  156 
  157         /* if request is off the end or trying to write last block on out */
  158 
  159         blkaddr = SECSIZE*bp->b_blkno;
  160         if ( (blkaddr >  md_size) ||
  161              (blkaddr == md_size & !(bp->b_flags & B_READ))) {
  162                 bp->b_flags = B_ERROR;
  163                 bp->b_error = ENXIO;
  164                 biodone(bp);
  165                 return;
  166         }
  167 
  168         if (blkaddr == md_size) {
  169         /* indicate (read) EOF by setting b_resid to b_bcount on last block */ 
  170                 bp->b_resid = bp->b_bcount;
  171                 biodone(bp);
  172                 return;
  173         }
  174 
  175 
  176         old_priority = spl5();
  177 
  178         if (bp->b_flags & B_READ) {
  179                 bcopy(  md_address + blkaddr,
  180                         bp->b_un.b_addr,
  181                         bp->b_bcount);
  182         } else {
  183                 bcopy(  bp->b_un.b_addr,
  184                         md_address + blkaddr,
  185                         bp->b_bcount);
  186         }
  187         bp->b_resid = 0;
  188         biodone(bp);
  189 
  190         splx(old_priority);
  191 }
  192 
  193 
  194 mdsize()
  195 {
  196         printf("mdsize()        -- not implemented\n");
  197 }
  198 
  199 mddump()
  200 {
  201         printf("mddump()        -- not implemented\n");
  202 }
  203 
  204 md_get_status(dev, flavor, status, count)
  205         dev_t   dev;
  206         int     *status, *count;
  207 {
  208         if (flavor == DEV_GET_SIZE) {
  209                 status[DEV_GET_SIZE_DEVICE_SIZE] = md_size * SECSIZE;
  210                 status[DEV_GET_SIZE_RECORD_SIZE] = SECSIZE;
  211                 *count = DEV_GET_SIZE_COUNT;
  212                 
  213                 return D_SUCCESS;
  214         } else return D_INVALID_OPERATION;
  215 }
  216 
  217 #endif  MACH_KERNEL

Cache object: 00c9de3f4449b10df5a3e3c0a0ccb82e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.