2 * Copyright (c) 2008-2009 TAKAHASHI Yoshihiro
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 /* Memory Locations */
30 .set STACK_OFF,0x6000 # Stack offset
31 .set LOAD_SIZE,8192 # Load size
32 .set DAUA,0x0584 # DA/UA
33 .set MEM_REL,0x700 # Relocation address
34 .set MEM_ARG,0x900 # Arguments
35 .set MEM_BUF,0x8cec # Load area
36 .set MEM_BTX,0x9000 # BTX start
37 .set MEM_JMP,0x9010 # BTX entry point
38 .set MEM_USR,0xa000 # Client start
40 /* PC98 machine type from sys/pc98/pc98/pc98_machdep.h */
41 .set MEM_SYS, 0xa100 # System common area segment
42 .set PC98_MACHINE_TYPE, 0x0620 # PC98 machine type
43 .set EPSON_ID, 0x0624 # EPSON machine id
45 .set M_NEC_PC98, 0x0001
46 .set M_EPSON_PC98, 0x0002
47 .set M_NOT_H98, 0x0010
53 /* Partition Constants */
54 .set PRT_OFF,0x1be # Partition offset
57 .set SIZ_PAG,0x1000 # Page size
58 .set SIZ_SEC,0x200 # Sector size
81 /* Relocate ourself to MEM_REL */
90 /* Transfer PC-9801 system common area */
101 /* Transfer EPSON machine type */
106 mov %eax,%es:(EPSON_ID)
108 /* Set machine type to PC98_SYSTEM_PARAMETER */
109 #ifdef SET_MACHINE_TYPE
110 call set_machine_type
112 mov $M_NEC_PC98+M_NOT_H98,%eax
113 mov %eax,%es:(PC98_MACHINE_TYPE)
116 /* Setup graphic screen */
117 mov $0x42,%ah /* 640x400 */
120 mov $0x40,%ah /* graph on */
123 /* Setup text screen */
124 mov $0x0a00,%ax /* 80x25 */
126 mov $0x0c,%ah /* text on */
128 mov $0x13,%ah /* cursor home */
131 mov $0x11,%ah /* cursor on */
140 /* bootstrap passes */
158 boot_hd: test %cx,%cx
160 mov %cs:(boot_cyl),%cx
161 boot_load: mov %cx,MEM_ARG /* Save cylinder number */
170 /* Transfer boot2.bin */
172 mov 0xa(%bx),%si /* BTX size */
173 add %bx,%si /* start of boot2.bin */
174 mov $MEM_USR+SIZ_PAG*2,%di
175 mov $MEM_BTX+(NSECT-1)*SIZ_SEC,%cx
187 ljmp $0x0000,$MEM_JMP
190 * Reads sectors from the disk.
193 * %bx - bytes to read
198 * %es:(%bp) - buffer to read data into
206 cmp $0x30,%al /* 1.44MB FDD */
208 cmp $0x90,%al /* 1MB FDD */
210 cmp $0xa0,%al /* Is SCSI device? */
217 shr %cl,%ah /* Is SCSI HDD? */
220 and $0xff7f,%si /* SCSI MO */
225 read_fd: or $0xd000,%si
228 read_load: mov %si,%ax
233 * Print out the error message, wait for a keypress, and then reboot
240 xor %ax,%ax /* Get keypress */
242 xor %ax,%ax /* CPU reset */
248 * Display a null-terminated string.
258 * Display a single char.
263 mov MEM_REL+cursor-start,%di
274 cmp $0x5c,%al /* \ */
277 1: movb $0xe1,%es:0x2000(%di)
280 putc.bs: test %di,%di
284 movb $0xe1,%es:0x2000(%di)
292 putc.scr: cmp $(80*2*25),%di /* Scroll screen */
308 putc.move: mov %di,MEM_REL+cursor-start /* Move cursor */
317 #ifdef SET_MACHINE_TYPE
319 * Set machine type to PC98_SYSTEM_PARAMETER.
328 vsync.1: inb $0x60,%al
331 vsync.2: inb $0x60,%al
341 /* Get 'A' font from CG window */
348 font.1: add (%bx),%eax
355 m_pc98: or $M_NEC_PC98,%edx
362 m_epson: or $M_EPSON_PC98,%edx
363 m_not_h98: or $M_NOT_H98,%edx
376 1: mov $PC98_MACHINE_TYPE,%bx
383 msg_eread: .asciz "Error\r\n"
387 /* Partition table */
390 .byte 0x80, 0x00, 0x01, 0x00
391 .byte 0xa5, 0xff, 0xff, 0xff
392 .byte 0x00, 0x00, 0x00, 0x00
393 .byte 0x50, 0xc3, 0x00, 0x00
395 .word 0xaa55 # Magic number