/* $NetBSD: diskio.c,v 1.9 2021/05/17 19:31:38 mrg Exp $ */ /* * Copyright (c) 1995 Waldi Ravens. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Waldi Ravens. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "atari_stand.h" #include #include typedef int (*rdsec_f)(void *buffer, u_int offset, u_int count); typedef struct { rdsec_f rds; u_int rst; u_int rend; } bdevd_t; static int rootstrategy(void *, int, daddr_t, size_t, void *, size_t *); static int rootopen(struct open_file *, ...); static int rootclose(struct open_file *); static int rootioctl(struct open_file *, u_long, void *); struct devsw devsw[] = { { "root", rootstrategy, rootopen, rootclose, rootioctl } }; static bdevd_t bootdev; /* * Initialise boot device info. */ int init_dskio (void *func, void *label, int root) { struct disklabel *dl = label; struct partition *pd = &dl->d_partitions[root]; if (dl->d_magic != DISKMAGIC || dl->d_magic2 != DISKMAGIC || dl->d_npartitions > MAXPARTITIONS || dkcksum(dl) != 0) { printf("Invalid disk label.\n"); return(-1); } if (root >= 0) { if (root >= dl->d_npartitions || pd->p_fstype != FS_BSDFFS || pd->p_size == 0) { printf("No suitable root.\n"); return(-1); } bootdev.rds = func; bootdev.rst = pd->p_offset; bootdev.rend = pd->p_offset + pd->p_size - 1; } return(0); } /* * No choice, the kernel is loaded from the * same device as the bootstrap. */ int devopen (struct open_file *f, const char *fname, char **file) { f->f_devdata = &bootdev; f->f_dev = &devsw[0]; *file = (char *)fname; return(0); } static int rootstrategy (void *devd, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize) { bdevd_t *dd = devd; daddr_t stb = dd->rst + dblk; size_t nb = size >> 9; if ((flag == F_READ) && !(size & 511) && (stb + nb <= dd->rend)) { if (!dd->rds(buf, stb, nb)) { *rsize = size; return(0); } } *rsize = 0; return(EIO); } static int rootopen (struct open_file *f, ...) { return(0); } static int rootclose (struct open_file *f) { return(EIO); } static int rootioctl (struct open_file *f, u_long cmd, void *data) { return(EIO); } over-highlight'> 2016-12-14Move vnode members "v_freelisthd" and "v_freelist" from "struct vnode"hannken to "struct vnode_impl" and rename to "vi_lrulisthd" and "vi_lrulist". No functional change intended. Welcome to 7.99.48 2016-08-19Remove the last references to KMEMSTATS.maxv 2016-05-12make '$e' in here the whole structure instead of a pointer, to combinemrg several pointer derefs into one speaking this up significantly. 2016-05-11Add kernhist to SYS_GDBINITskrll 2016-05-11add a gdb script to dump kernel histories. based upon a script by skrll,mrg updated by myself to run faster and more stupidly (but more workingly.) normal gdb scripts don't seem to be able to call printf with the format string as a variable, so we simply print the format itself as a string and the (upto 4) arguments as unsigned long (how they're strored.) 2013-11-23Since mountlist is now a TAILQ, convert some missed usagesriz so things build again. 2013-03-06update scriptyamt comment and example 2011-11-02a macro to dump kernel modulesyamt 2011-02-05fix formatyamt 2009-11-18Add a command to dump all thread stacks in the system and a command to dumpeeh lockdebug state. 2009-11-18Add the lwp address so you don't have to leave gdb and use ps to grab an lwp'seeh stack. 2009-11-18Print out all 64-bits of 64-bit values on 64-bit machines and add documentationeeh of these commands to gdb. 2009-11-18Get gdb to document the command.eeh 2009-07-28Use the right pointer to traverse the proc's lwp list.skrll From PR 41788. 2008-04-30Convert TNF licenses to new 2 clause variantmartin 2008-02-20+cpusad 2008-02-20- Replace 'xps' with 'procs' and 'lwps'.ad - Needs a bit more work. 2008-02-20stats is gonead 2008-02-20This is useless!ad 2006-11-04adapt to mnt_vnodelist being TAILQpooka 2006-11-04add mountdump, prints mount point information a little like mount(8)pooka 2006-09-29Make these work again. I know, I'm a bit impatient, since they'vepooka only been broken for 12 years, but some things are better done sooner than later. While meddling here, introduce mp_vchain, which prints the vnode chain given a mount point. 2005-12-11merge ktrace-lwp.christos 2005-02-26nuke trailing whitespaceperry 2003-04-28Clean up the output a little and print the lwp pointer.briggs 2003-02-26adapt to lwp-worldlha 2002-09-01Build a .gdbinit in the kernel build directory. The new .gdbinitthorpej will source all of the system-provided gdb scrips in sys/gdbscripts, as well as any files specified by the user in the GDBINIT make var. 2001-01-11fix pointer arithmeticdeberg 2000-06-08gdb macro to print the kernel message bufferjhawk 1997-04-16widen proc pointer and wchan pointer fields from 10 to 18 characters, socgd that pointers on 64-bit systems are printed properly. This means that there'll be a lot of extra space on 32-bit systems, but gdb's printf doesn't support * for width or precision specifiers, so it can't really be done much better. 1997-02-12Add NetBSD cvs id lines.gwr 1997-02-12Macros for gdb when debugging the kernel (from 4.4-Lite2).gwr