Home | History | Annotate | Line # | Download | only in common
      1 /*	$NetBSD: bootxx.h,v 1.3 2008/04/28 20:23:18 martin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2004 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by UCHIYAMA Yasushi.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifdef _STANDALONE
     33 #include <lib/libkern/libkern.h>
     34 #endif
     35 
     36 enum {
     37 	BERR_NONE,
     38 	BERR_PDINFO,
     39 	BERR_RDVTOC,
     40 	BERR_VTOC,
     41 	BERR_NOBFS,
     42 	BERR_RDINODE,
     43 	BERR_NOROOT,
     44 	BERR_RDDIRENT,
     45 	BERR_NOFILE,
     46 	BERR_RDFILE,
     47 	BERR_FILEMAGIC,
     48 	BERR_AOUTHDR,
     49 	BERR_ELFHDR,
     50 	BERR_TARHDR,
     51 	BERR_TARMAGIC,
     52 };
     53 int dk_read(int, int, void *);
     54 int fileread(const char *, size_t *);
     55 
     56 #ifdef _STANDALONE
     57 #define	BASSERT(x)		((void)0)
     58 #define	DPRINTF(arg...)		((void)0)
     59 #define	SDBOOT_LOADADDR		0xa0190000
     60 #define	SDBOOT_PDINFOADDR	0xa0191000
     61 #define	SDBOOT_VTOCADDR		0xa0191400
     62 #define	SDBOOT_INODEADDR	0xa0191600
     63 #define	SDBOOT_DIRENTADDR	0xa0191800
     64 #define	SDBOOT_SCRATCHADDR	0xa0200000
     65 #else
     66 #include <stdio.h>
     67 #include <string.h>
     68 #include <assert.h>
     69 #define	BASSERT(x)		assert(x)
     70 #define	DPRINTF(fmt, args...)	printf(fmt, ##args)
     71 uint8_t __buf0[512];
     72 uint8_t __buf1[512];
     73 uint8_t __buf2[512];
     74 uint8_t __buf3[512];
     75 uint8_t __buf4[4 * 1024 * 1024];
     76 #define	SDBOOT_PDINFOADDR	__buf0
     77 #define	SDBOOT_VTOCADDR		__buf1
     78 #define	SDBOOT_INODEADDR	__buf2
     79 #define	SDBOOT_DIRENTADDR	__buf3
     80 #define	SDBOOT_SCRATCHADDR	__buf4
     81 void sector_init(const char *, int);
     82 #endif
     83