1 /* $NetBSD: bootxx.c,v 1.9 2008/01/11 09:26:27 tsutsui Exp $ */
4 * Copyright (c) 1999 Izumi Tsutsui. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. The name of the author may not be used to endorse or promote products
39 * derived from this software without specific prior written permission.
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <lib/libkern/libkern.h>
54 #include <lib/libsa/stand.h>
55 #include <machine/romcall.h>
57 #include <sys/bootblock.h>
59 void bootxx(uint32_t, uint32_t, uint32_t, uint32_t);
61 struct shared_bbinfo bbinfo
= {
62 { NEWS68K_BBINFO_MAGIC
}, /* bbi_magic[] */
63 0, /* bbi_block_size */
64 SHARED_BBINFO_MAXBLOCKS
, /* bbi_block_count */
65 { 0 }, /* bbi_block_table[] */
68 #ifndef DEFAULT_ENTRY_POINT
69 #define DEFAULT_ENTRY_POINT 0x003e0000
71 void (*entry_point
)(uint32_t, uint32_t, uint32_t, uint32_t) =
72 (void *)DEFAULT_ENTRY_POINT
;
75 # define DPRINTF printf
77 # define DPRINTF while (0) printf
80 char *devs
[] = { "hd", "fh", "fd", NULL
, NULL
, "rd", "st" };
83 bootxx(uint32_t d4
, uint32_t d5
, uint32_t d6
, uint32_t d7
)
86 int ctlr
, unit
, part
, type
;
92 printf("NetBSD/news68k Primary Boot\n");
95 DPRINTF("d4 %x\n", d4
);
96 DPRINTF("d5 %x (%s)\n", d5
, (char *)d5
);
97 DPRINTF("d6 %x\n", d6
);
98 DPRINTF("d7 %x\n", d7
);
100 DPRINTF("block_size = %d\n", bbinfo
.bbi_block_size
);
101 DPRINTF("block_count = %d\n", bbinfo
.bbi_block_count
);
102 DPRINTF("entry_point = %p\n", entry_point
);
104 /* sd(ctlr, lun, part, bus?, host) */
106 ctlr
= BOOTDEV_CTLR(bootdev
);
107 unit
= BOOTDEV_UNIT(bootdev
);
108 part
= BOOTDEV_PART(bootdev
);
109 type
= BOOTDEV_TYPE(bootdev
);
111 if (devs
[type
] == NULL
) {
112 printf("unknown bootdev (0x%x)\n", bootdev
);
116 sprintf(devname
, "%s(%d,%d,%d)", devs
[type
], ctlr
, unit
, part
);
118 fd
= rom_open(devname
, 0);
120 printf("cannot open %s\n", devname
);
124 addr
= (char *)entry_point
;
125 bs
= bbinfo
.bbi_block_size
;
126 DPRINTF("reading block:");
127 for (i
= 0; i
< bbinfo
.bbi_block_count
; i
++) {
128 blk
= bbinfo
.bbi_block_table
[i
];
132 rom_lseek(fd
, blk
* 512, 0);
133 rom_read(fd
, addr
, bs
);
139 (*entry_point
)(d4
, d5
, d6
, d7
);
140 DPRINTF("bootxx returned?\n");