1201339Snyan/*- 2201339Snyan * Copyright (c) 2009 TAKAHASHI Yoshihiro <nyan@FreeBSD.org> 3201339Snyan * All rights reserved. 4201339Snyan * 5201339Snyan * Redistribution and use in source and binary forms, with or without 6201339Snyan * modification, are permitted provided that the following conditions 7201339Snyan * are met: 8201339Snyan * 1. Redistributions of source code must retain the above copyright 9201339Snyan * notice, this list of conditions and the following disclaimer. 10201339Snyan * 2. Redistributions in binary form must reproduce the above copyright 11201339Snyan * notice, this list of conditions and the following disclaimer in the 12201339Snyan * documentation and/or other materials provided with the distribution. 13201339Snyan * 14201339Snyan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15201339Snyan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16201339Snyan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17201339Snyan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18201339Snyan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19201339Snyan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20201339Snyan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21201339Snyan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22201339Snyan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23201339Snyan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24201339Snyan * SUCH DAMAGE. 25201339Snyan * 26201339Snyan */ 27201339Snyan 28201339Snyan#include <sys/cdefs.h> 29201339Snyan__FBSDID("$FreeBSD: stable/11/stand/pc98/libpc98/pc98_sys.c 201339 2009-12-31 12:05:48Z nyan $"); 30201339Snyan 31201339Snyan#include <btxv86.h> 32201339Snyan#include <machine/cpufunc.h> 33201339Snyan#define _KERNEL 34201339Snyan#include <pc98/pc98/pc98_machdep.h> 35201339Snyan 36201339Snyan/* 37201339Snyan * Set machine type to PC98_SYSTEM_PARAMETER. 38201339Snyan */ 39201339Snyanvoid 40201339Snyanset_machine_type(void) 41201339Snyan{ 42201339Snyan int i; 43201339Snyan u_long ret, data; 44201339Snyan 45201339Snyan /* PC98_SYSTEM_PARAMETER (0x501) */ 46201339Snyan ret = ((*(u_char *)PTOV(0xA1501)) & 0x08) >> 3; 47201339Snyan 48201339Snyan /* Wait V-SYNC */ 49201339Snyan while (inb(0x60) & 0x20) {} 50201339Snyan while (!(inb(0x60) & 0x20)) {} 51201339Snyan 52201339Snyan /* ANK 'A' font */ 53201339Snyan outb(0xa1, 0x00); 54201339Snyan outb(0xa3, 0x41); 55201339Snyan 56201339Snyan /* M_NORMAL, use CG window (all NEC OK) */ 57201339Snyan for (i = data = 0; i < 4; i++) 58201339Snyan data += *((u_long *)PTOV(0xA4000) + i); /* 0xa4000 */ 59201339Snyan if (data == 0x6efc58fc) /* DA data */ 60201339Snyan ret |= M_NEC_PC98; 61201339Snyan else 62201339Snyan ret |= M_EPSON_PC98; 63201339Snyan ret |= (inb(0x42) & 0x20) ? M_8M : 0; 64201339Snyan 65201339Snyan /* PC98_SYSTEM_PARAMETER(0x400) */ 66201339Snyan if ((*(u_char *)PTOV(0xA1400)) & 0x80) 67201339Snyan ret |= M_NOTE; 68201339Snyan if (ret & M_NEC_PC98) { 69201339Snyan /* PC98_SYSTEM_PARAMETER(0x458) */ 70201339Snyan if ((*(u_char *)PTOV(0xA1458)) & 0x80) 71201339Snyan ret |= M_H98; 72201339Snyan else 73201339Snyan ret |= M_NOT_H98; 74201339Snyan } else 75201339Snyan ret |= M_NOT_H98; 76201339Snyan 77201339Snyan (*(u_long *)PTOV(0xA1620)) = ret; 78201339Snyan} 79