diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index c8c0b52d4c05..47027cd83dfb 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -2,7 +2,7 @@ # files marked standard are always included. # # modified for PC-9801 after: -# $Id: files.pc98,v 1.3 1996/08/31 15:06:30 asami Exp $ +# $Id: files.pc98,v 1.4 1996/09/03 10:23:12 asami Exp $ # aic7xxx_asm optional ahc device-driver \ dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \ @@ -29,7 +29,7 @@ linux_assym.h optional compat_linux \ clean "linux_assym.h" # i386/scsi/93cx6.c optional ahc device-driver -pc98/apm/apm.c optional apm device-driver +i386/apm/apm.c optional apm device-driver i386/apm/apm_setup.s optional apm #i386/eisa/3c5x9.c optional ep device-driver #i386/eisa/aic7770.c optional ahc device-driver @@ -131,8 +131,8 @@ pc98/pc98/npx.c optional npx device-driver pc98/pc98/pcaudio.c optional pca device-driver pc98/pc98/matcd/matcd.c optional matcd device-driver pc98/pc98/pcibus.c optional pci device-driver -pc98/pc98/pcicx.c optional ze device-driver -pc98/pc98/pcicx.c optional zp device-driver +i386/isa/pcicx.c optional ze device-driver +i386/isa/pcicx.c optional zp device-driver pc98/isa/pcvt/pcvt_drv.c optional vt device-driver pc98/isa/pcvt/pcvt_ext.c optional vt device-driver pc98/isa/pcvt/pcvt_kbd.c optional vt device-driver @@ -145,7 +145,7 @@ pc98/isa/qcam.c optional qcam device-driver pc98/isa/qcamio.c optional qcam device-driver pc98/pc98/random_machdep.c standard pc98/isa/rc.c optional rc device-driver -pc98/pc98/scd.c optional scd device-driver +i386/isa/scd.c optional scd device-driver pc98/isa/seagate.c optional sea device-driver pc98/isa/si.c optional si device-driver pc98/isa/si_code.c optional si device-driver diff --git a/sys/i386/isa/isa_device.h b/sys/i386/isa/isa_device.h index 996a08a0054d..3612bb4aa575 100644 --- a/sys/i386/isa/isa_device.h +++ b/sys/i386/isa/isa_device.h @@ -31,13 +31,9 @@ * SUCH DAMAGE. * * from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91 - * $Id: isa_device.h,v 1.29 1996/04/08 19:38:57 smpatel Exp $ + * $Id: isa_device.h,v 1.30 1996/06/14 11:01:19 asami Exp $ */ -#ifdef PC98 -#error isa_device.h is included from PC-9801 source -#endif - #ifndef _I386_ISA_ISA_DEVICE_H_ #define _I386_ISA_ISA_DEVICE_H_ diff --git a/sys/pc98/conf/files.pc98 b/sys/pc98/conf/files.pc98 index c8c0b52d4c05..47027cd83dfb 100644 --- a/sys/pc98/conf/files.pc98 +++ b/sys/pc98/conf/files.pc98 @@ -2,7 +2,7 @@ # files marked standard are always included. # # modified for PC-9801 after: -# $Id: files.pc98,v 1.3 1996/08/31 15:06:30 asami Exp $ +# $Id: files.pc98,v 1.4 1996/09/03 10:23:12 asami Exp $ # aic7xxx_asm optional ahc device-driver \ dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \ @@ -29,7 +29,7 @@ linux_assym.h optional compat_linux \ clean "linux_assym.h" # i386/scsi/93cx6.c optional ahc device-driver -pc98/apm/apm.c optional apm device-driver +i386/apm/apm.c optional apm device-driver i386/apm/apm_setup.s optional apm #i386/eisa/3c5x9.c optional ep device-driver #i386/eisa/aic7770.c optional ahc device-driver @@ -131,8 +131,8 @@ pc98/pc98/npx.c optional npx device-driver pc98/pc98/pcaudio.c optional pca device-driver pc98/pc98/matcd/matcd.c optional matcd device-driver pc98/pc98/pcibus.c optional pci device-driver -pc98/pc98/pcicx.c optional ze device-driver -pc98/pc98/pcicx.c optional zp device-driver +i386/isa/pcicx.c optional ze device-driver +i386/isa/pcicx.c optional zp device-driver pc98/isa/pcvt/pcvt_drv.c optional vt device-driver pc98/isa/pcvt/pcvt_ext.c optional vt device-driver pc98/isa/pcvt/pcvt_kbd.c optional vt device-driver @@ -145,7 +145,7 @@ pc98/isa/qcam.c optional qcam device-driver pc98/isa/qcamio.c optional qcam device-driver pc98/pc98/random_machdep.c standard pc98/isa/rc.c optional rc device-driver -pc98/pc98/scd.c optional scd device-driver +i386/isa/scd.c optional scd device-driver pc98/isa/seagate.c optional sea device-driver pc98/isa/si.c optional si device-driver pc98/isa/si_code.c optional si device-driver diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index 4486b6547f98..a7c4dbca5b1c 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.3 1996/08/30 10:42:53 asami Exp $ + * $Id: machdep.c,v 1.4 1996/09/03 10:23:16 asami Exp $ */ #include "npx.h" @@ -1114,39 +1114,63 @@ init386(first) biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); /* - * Print a warning and set it to the safest value if the official - * BIOS interface (bootblock supplied) disagrees with the - * hackish interface used above. Eventually only the official - * interface should be used. This is necessary for some machines - * who 'steal' memory from the basemem for use as BIOS memory. + * If BIOS tells us that it has more than 640k in the basemem, + * don't believe it - set it to 640k. + */ + if (biosbasemem > 640) { + printf("Preposterous RTC basemem of %dK, truncating to 640K\n", + biosbasemem); + biosbasemem = 640; + } + if (bootinfo.bi_memsizes_valid && bootinfo.bi_basemem > 640) { + printf("Preposterous BIOS basemem of %dK, truncating to 640K\n", + bootinfo.bi_basemem); + bootinfo.bi_basemem = 640; + } + + /* + * Warn if the official BIOS interface disagrees with the RTC + * interface used above about the amount of base memory or the + * amount of extended memory. Prefer the BIOS value for the base + * memory. This is necessary for machines that `steal' base + * memory for use as BIOS memory, at least if we are going to use + * the BIOS for apm. Prefer the RTC value for extended memory. + * Eventually the hackish interface shouldn't even be looked at. */ if (bootinfo.bi_memsizes_valid) { if (bootinfo.bi_basemem != biosbasemem) { - vm_offset_t pa, va, tmpva; - vm_size_t size; - unsigned *pte; + vm_offset_t pa; - printf("BIOS basemem (%ldK) != RTC basemem (%dK), ", - bootinfo.bi_basemem, biosbasemem); - printf("setting to BIOS value.\n"); + printf( + "BIOS basemem (%ldK) != RTC basemem (%dK), setting to BIOS value\n", biosbasemem = bootinfo.bi_basemem; + /* - * XXX - Map this 'hole' of memory in the same manner - * as the ISA_HOLE (read/write/non-cacheable), since - * the BIOS 'fudges' it to become part of the ISA_HOLE. + * XXX if biosbasemem is now < 640, there is `hole' + * between the end of base memory and the start of + * ISA memory. The hole may be empty or it may + * contain BIOS code or data. Map it read/write so + * that the BIOS can write to it. (Memory from 0 to + * the physical end of the kernel is mapped read-only + * to begin with and then parts of it are remapped. + * The parts that aren't remapped form holes that + * remain read-only and are unused by the kernel. + * The base memory area is below the physical end of + * the kernel and right now forms a read-only hole. + * The part of it from 0 to + * (trunc_page(biosbasemem * 1024) - 1) will be + * remapped and used by the kernel later.) + * * This code is similar to the code used in * pmap_mapdev, but since no memory needs to be * allocated we simply change the mapping. */ - pa = biosbasemem * 1024; - va = pa + KERNBASE; - size = roundup(ISA_HOLE_START - pa, PAGE_SIZE); - for (tmpva = va; size > 0;) { - pte = (unsigned *)vtopte(tmpva); - *pte = pa | PG_RW | PG_V | PG_N; - size -= PAGE_SIZE; - tmpva += PAGE_SIZE; - pa += PAGE_SIZE; + for (pa = trunc_page(biosbasemem * 1024); + pa < ISA_HOLE_START; pa += PAGE_SIZE) { + unsigned *pte; + + pte = (unsigned *)vtopte(pa + KERNBASE); + *pte = pa | PG_RW | PG_V; } } if (bootinfo.bi_extmem != biosextmem) @@ -1155,13 +1179,6 @@ init386(first) } #endif - /* - * If BIOS tells us that it has more than 640k in the basemem, - * don't believe it - set it to 640k. - */ - if (biosbasemem > 640) - biosbasemem = 640; - /* * Some 386 machines might give us a bogus number for extended * mem. If this happens, stop now. diff --git a/sys/pc98/i386/trap.c b/sys/pc98/i386/trap.c index c55daf444dba..fb294dca4974 100644 --- a/sys/pc98/i386/trap.c +++ b/sys/pc98/i386/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.3 1996/08/30 10:42:54 asami Exp $ + * $Id: trap.c,v 1.4 1996/09/03 10:23:17 asami Exp $ */ /* @@ -165,7 +165,7 @@ userret(p, frame, oticks) * mi_switch()'ed, we might not be on the queue indicated by * our priority. */ - s = splclock(); + s = splhigh(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 4486b6547f98..a7c4dbca5b1c 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.3 1996/08/30 10:42:53 asami Exp $ + * $Id: machdep.c,v 1.4 1996/09/03 10:23:16 asami Exp $ */ #include "npx.h" @@ -1114,39 +1114,63 @@ init386(first) biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); /* - * Print a warning and set it to the safest value if the official - * BIOS interface (bootblock supplied) disagrees with the - * hackish interface used above. Eventually only the official - * interface should be used. This is necessary for some machines - * who 'steal' memory from the basemem for use as BIOS memory. + * If BIOS tells us that it has more than 640k in the basemem, + * don't believe it - set it to 640k. + */ + if (biosbasemem > 640) { + printf("Preposterous RTC basemem of %dK, truncating to 640K\n", + biosbasemem); + biosbasemem = 640; + } + if (bootinfo.bi_memsizes_valid && bootinfo.bi_basemem > 640) { + printf("Preposterous BIOS basemem of %dK, truncating to 640K\n", + bootinfo.bi_basemem); + bootinfo.bi_basemem = 640; + } + + /* + * Warn if the official BIOS interface disagrees with the RTC + * interface used above about the amount of base memory or the + * amount of extended memory. Prefer the BIOS value for the base + * memory. This is necessary for machines that `steal' base + * memory for use as BIOS memory, at least if we are going to use + * the BIOS for apm. Prefer the RTC value for extended memory. + * Eventually the hackish interface shouldn't even be looked at. */ if (bootinfo.bi_memsizes_valid) { if (bootinfo.bi_basemem != biosbasemem) { - vm_offset_t pa, va, tmpva; - vm_size_t size; - unsigned *pte; + vm_offset_t pa; - printf("BIOS basemem (%ldK) != RTC basemem (%dK), ", - bootinfo.bi_basemem, biosbasemem); - printf("setting to BIOS value.\n"); + printf( + "BIOS basemem (%ldK) != RTC basemem (%dK), setting to BIOS value\n", biosbasemem = bootinfo.bi_basemem; + /* - * XXX - Map this 'hole' of memory in the same manner - * as the ISA_HOLE (read/write/non-cacheable), since - * the BIOS 'fudges' it to become part of the ISA_HOLE. + * XXX if biosbasemem is now < 640, there is `hole' + * between the end of base memory and the start of + * ISA memory. The hole may be empty or it may + * contain BIOS code or data. Map it read/write so + * that the BIOS can write to it. (Memory from 0 to + * the physical end of the kernel is mapped read-only + * to begin with and then parts of it are remapped. + * The parts that aren't remapped form holes that + * remain read-only and are unused by the kernel. + * The base memory area is below the physical end of + * the kernel and right now forms a read-only hole. + * The part of it from 0 to + * (trunc_page(biosbasemem * 1024) - 1) will be + * remapped and used by the kernel later.) + * * This code is similar to the code used in * pmap_mapdev, but since no memory needs to be * allocated we simply change the mapping. */ - pa = biosbasemem * 1024; - va = pa + KERNBASE; - size = roundup(ISA_HOLE_START - pa, PAGE_SIZE); - for (tmpva = va; size > 0;) { - pte = (unsigned *)vtopte(tmpva); - *pte = pa | PG_RW | PG_V | PG_N; - size -= PAGE_SIZE; - tmpva += PAGE_SIZE; - pa += PAGE_SIZE; + for (pa = trunc_page(biosbasemem * 1024); + pa < ISA_HOLE_START; pa += PAGE_SIZE) { + unsigned *pte; + + pte = (unsigned *)vtopte(pa + KERNBASE); + *pte = pa | PG_RW | PG_V; } } if (bootinfo.bi_extmem != biosextmem) @@ -1155,13 +1179,6 @@ init386(first) } #endif - /* - * If BIOS tells us that it has more than 640k in the basemem, - * don't believe it - set it to 640k. - */ - if (biosbasemem > 640) - biosbasemem = 640; - /* * Some 386 machines might give us a bogus number for extended * mem. If this happens, stop now. diff --git a/sys/pc98/pc98/mk30line b/sys/pc98/pc98/mk30line deleted file mode 100644 index 18ebfd6ecde0..000000000000 --- a/sys/pc98/pc98/mk30line +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) KATO Takenori, 1994-1995. 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 as -# the first lines of this file unmodified. -# 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. 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. -# - -# Default -($HS, $VS, $HBP, $HFP, $VBP, $VFP) = (7, 8, 7, 9, 25, 7); - -# set module name -print("Enter module file name: "); -$module = ; -open(MODULE, "<$module") || die "Can't open $module.\n"; - -# read module file -while () { - if (/\t\tdb\t255/) { - ($HS, $VS, $HBP, $HFP, $VBP, $VFP) = - /^\t\tdb\t255, (\d+)\+1,(\d+), (\d+)\+1,(\d+)\+1, (\d+),(\d+).*/; - } -} -close(MODULE); - -print("Enter number of lines: "); -$ROW = ; - -# open /sys/pc98/pc98/module.h -open(MODULE_H, ">/sys/pc98/pc98/module.h") || die "Can't open module.h\n"; - -# write -printf(MODULE_H "#define\tLINE30_ROW\t%d\n", $ROW); -printf(MODULE_H "#define\t_HS\t%d + 1\n", $HS); -printf(MODULE_H "#define\t_VS\t%d\n", $VS); -printf(MODULE_H "#define\t_HFP\t%d + 1\n", $HFP); -printf(MODULE_H "#define\t_HBP\t%d + 1\n", $HBP); -printf(MODULE_H "#define\t_VFP\t%d\n", $VFP); -printf(MODULE_H "#define\t_VBP\t%d\n", $VBP); -close(MODULE_H); - diff --git a/sys/pc98/pc98/pcic.h b/sys/pc98/pc98/pcic.h deleted file mode 100644 index bc5ae5e35610..000000000000 --- a/sys/pc98/pc98/pcic.h +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * TODO: - * [1] integrate into current if_ed.c - * [2] parse tuples to find out where to map the shared memory buffer, - * and what to write into the configuration register - * [3] move pcic-specific code into a separate module. - * - * Device driver for IBM PCMCIA Credit Card Adapter for Ethernet, - * if_ze.c - * - * Based on the Device driver for National Semiconductor DS8390 ethernet - * adapters by David Greenman. Modifications for PCMCIA by Keith Moore. - * Adapted for FreeBSD 1.1.5 by Jordan Hubbard. - * - * Currently supports only the IBM Credit Card Adapter for Ethernet, but - * could probably work with other PCMCIA cards also, if it were modified - * to get the locations of the PCMCIA configuration option register (COR) - * by parsing the configuration tuples, rather than by hard-coding in - * the value expected by IBM's card. - * - * Sources for data on the PCMCIA/IBM CCAE specific portions of the driver: - * - * [1] _Local Area Network Credit Card Adapters Technical Reference_, - * IBM Corp., SC30-3585-00, part # 33G9243. - * [2] "pre-alpha" PCMCIA support code for Linux by Barry Jaspan. - * [3] Intel 82536SL PC Card Interface Controller Data Sheet, Intel - * Order Number 290423-002 - * [4] National Semiconductor DP83902A ST-NIC (tm) Serial Network - * Interface Controller for Twisted Pair data sheet. - * - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - */ - -#ifndef __PCIC_H__ -#define __PCIC_H__ - -/***************************************************************************** - * pcmcia controller chip (PCIC) support * - * (eventually, move this to a separate file) * - *****************************************************************************/ -#include "ic/i82365.h" - -/* - * Each PCIC chip (82365SL or clone) can handle two card slots, and there - * can be up to four PCICs in a system. (On some machines, not all of the - * address lines are decoded, so a card may appear to be in more than one - * slot.) - */ -#define MAXSLOT 8 - -/* - * To access a register on the PCIC for a particular slot, you - * first write the correct OFFSET value for that slot in the - * INDEX register for the PCIC controller. You then read or write - * the value from or to the DATA register for that controller. - * - * The first pair of chips shares I/O addresses for DATA and INDEX, - * as does the second pair. (To the programmer, it looks like each - * pair is a single chip.) The i/o port addresses are hard-wired - * into the PCIC; so the following addresses should be valid for - * any machine that uses this chip. - */ - -#define PCIC_INDEX_0 0x3E0 /* index reg, chips 0 and 1 */ -#define PCIC_DATA_0 0x3E1 /* data register, chips 0 and 1 */ -#define PCIC_INDEX_1 0x3E2 /* index reg, chips 1 and 2 */ -#define PCIC_DATA_1 0x3E3 /* data register, chips 1 and 2 */ - -/* - * Given a slot number, calculate the INDEX and DATA registers - * to talk to that slot. OFFSET is added to the register number - * to address the registers for a particular slot. - */ -#define INDEX(slot) ((slot) < 4 ? PCIC_INDEX_0 : PCIC_INDEX_1) -#define DATA(slot) ((slot) < 4 ? PCIC_DATA_0 : PCIC_DATA_1) -#define OFFSET(slot) ((slot) % 4 * 0x40) - -/* - * There are 5 sets (windows) of memory mapping registers on the PCIC chip - * for each slot, numbered 0..4. - * - * They start at 10/50 hex within the chip's register space (not system - * I/O space), and are eight addresses apart. These are actually pairs of - * 8-bit-wide registers (low byte first, then high byte) since the - * address fields are actually 12 bits long. The upper bits are used - * for other things like 8/16-bit select and wait states. - * - * Memory mapping registers include start/stop addresses to define the - * region to be mapped (in terms of system memory addresses), and - * an offset register to allow for translation from system space - * to card space. The lower 12 bits aren't included in these, so memory is - * mapped in 4K chunks. - */ -#define MEM_START_ADDR(window) (((window) * 0x08) + 0x10) -#define MEM_STOP_ADDR(window) (((window) * 0x08) + 0x12) -#define MEM_OFFSET(window) (((window) * 0x08) + 0x14) -/* - * this bit gets set in the address window enable register (PCIC_ADDRWINE) - * to enable a particular address window. - */ -#define MEM_ENABLE_BIT(window) ((1) << (window)) - -/* - * There are two i/o port addressing windows. I/O ports cannot be - * relocated within system i/o space (unless the card doesn't decode - * all of the address bits); unlike card memory, there is no address - * translation offset. - */ -#define IO_START_ADDR(window) ((window) ? PCIC_IO1_STL : PCIC_IO0_STL) -#define IO_STOP_ADDR(window) ((window) ? PCIC_IO1_SPL : PCIC_IO0_SPL) -#define IO_ENABLE_BIT(window) ((window) ? PCIC_IO1_EN : PCIC_IO0_EN) -#define IO_CS16_BIT(window) ((window) ? PCIC_IO1_CS16 : PCIC_IO0_CS16) - -/* - * types of mapped memory - */ -enum memtype { COMMON, ATTRIBUTE }; - -/* - * read a byte from a pcic register for a particular slot - */ -static inline unsigned char -pcic_getb (int slot, int reg) -{ - outb (INDEX(slot), OFFSET (slot) + reg); - return inb (DATA (slot)); -} - -/* - * write a byte to a pcic register for a particular slot - */ -static inline void -pcic_putb (int slot, int reg, unsigned char val) -{ - outb (INDEX(slot), OFFSET (slot) + reg); - outb (DATA (slot), val); -} - -/* - * read a word from a pcic register for a particular slot - */ -static inline unsigned short -pcic_getw (int slot, int reg) -{ - return pcic_getb (slot, reg) | (pcic_getb (slot, reg+1) << 8); -} - -/* - * write a word to a pcic register at a particular slot - */ -static inline void -pcic_putw (int slot, int reg, unsigned short val) -{ - pcic_putb (slot, reg, val & 0xff); - pcic_putb (slot, reg + 1, (val >> 8) & 0xff); -} - - -void pcic_print_regs (int slot); -void pcic_map_memory (int slot, int window, unsigned long sys_addr, - unsigned long card_addr, unsigned long length, - enum memtype type, int width); -void pcic_unmap_memory (int slot, int window); -void pcic_map_io (int slot, int window, unsigned short base, - unsigned short length, unsigned short width); -#ifdef TEST -void pcic_unmap_io (int slot, int window); -#endif /* TEST */ -void pcic_map_irq (int slot, int irq); -void pcic_power_on (int slot); -void pcic_power_off (int slot); -void pcic_reset (int slot); - - -#endif /* __PCIC_H__ */ diff --git a/sys/pc98/pc98/pcicx.c b/sys/pc98/pc98/pcicx.c deleted file mode 100644 index 757e2d767359..000000000000 --- a/sys/pc98/pc98/pcicx.c +++ /dev/null @@ -1,236 +0,0 @@ -/*- - * TODO: - * [1] integrate into current if_ed.c - * [2] parse tuples to find out where to map the shared memory buffer, - * and what to write into the configuration register - * [3] move pcic-specific code into a separate module. - * - * Device driver for IBM PCMCIA Credit Card Adapter for Ethernet, - * if_ze.c - * - * Based on the Device driver for National Semiconductor DS8390 ethernet - * adapters by David Greenman. Modifications for PCMCIA by Keith Moore. - * Adapted for FreeBSD 1.1.5 by Jordan Hubbard. - * - * Currently supports only the IBM Credit Card Adapter for Ethernet, but - * could probably work with other PCMCIA cards also, if it were modified - * to get the locations of the PCMCIA configuration option register (COR) - * by parsing the configuration tuples, rather than by hard-coding in - * the value expected by IBM's card. - * - * Sources for data on the PCMCIA/IBM CCAE specific portions of the driver: - * - * [1] _Local Area Network Credit Card Adapters Technical Reference_, - * IBM Corp., SC30-3585-00, part # 33G9243. - * [2] "pre-alpha" PCMCIA support code for Linux by Barry Jaspan. - * [3] Intel 82536SL PC Card Interface Controller Data Sheet, Intel - * Order Number 290423-002 - * [4] National Semiconductor DP83902A ST-NIC (tm) Serial Network - * Interface Controller for Twisted Pair data sheet. - * - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - */ -#include -#if defined(__FreeBSD__) -#include -#include -#include -#endif -#include -#ifdef PC98 -#include -#else -#include -#endif - -/* - * map a portion of the card's memory space into system memory - * space. - * - * slot = # of the slot the card is plugged into - * window = which pcic memory map registers to use (0..4) - * sys_addr = base system PHYSICAL memory address where we want it. must - * be on an appropriate boundary (lower 12 bits are zero). - * card_addr = the base address of the card's memory to correspond - * to sys_addr - * length = length of the segment to map (may be rounded up as necessary) - * type = which card memory space to map (attribute or shared) - * width = 1 for byte-wide mapping; 2 for word (16-bit) mapping. - */ - -void -pcic_map_memory (int slot, int window, unsigned long sys_addr, - unsigned long card_addr, unsigned long length, - enum memtype type, int width) -{ - unsigned short offset; - unsigned short mem_start_addr; - unsigned short mem_stop_addr; - - sys_addr >>= 12; - card_addr >>= 12; - length >>= 12; - /* - * compute an offset for the chip such that - * (sys_addr + offset) = card_addr - * but the arithmetic is done modulo 2^14 - */ - offset = (card_addr - sys_addr) & 0x3FFF; - /* - * now OR in the bit for "attribute memory" if necessary - */ - if (type == ATTRIBUTE) { - offset |= (PCIC_REG << 8); - /* REG == "region active" pin on card */ - } - /* - * okay, set up the chip memory mapping registers, and turn - * on the enable bit for this window. - * if we are doing 16-bit wide accesses (width == 2), - * turn on the appropriate bit. - * - * XXX for now, we set all of the wait state bits to zero. - * Not really sure how they should be set. - */ - mem_start_addr = sys_addr & 0xFFF; - if (width == 2) - mem_start_addr |= (PCIC_DATA16 << 8); - mem_stop_addr = (sys_addr + length) & 0xFFF; - - pcic_putw (slot, MEM_START_ADDR(window), mem_start_addr); - pcic_putw (slot, MEM_STOP_ADDR(window), mem_stop_addr); - pcic_putw (slot, MEM_OFFSET(window), offset); - /* - * Assert the bit (PCIC_MEMCS16) that says to decode all of - * the address lines. - */ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) | - MEM_ENABLE_BIT(window) | PCIC_MEMCS16); -} - -void -pcic_unmap_memory (int slot, int window) -{ - /* - * seems like we need to turn off the enable bit first, after which - * we can clear the registers out just to be sure. - */ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) & ~MEM_ENABLE_BIT(window)); - pcic_putw (slot, MEM_START_ADDR(window), 0); - pcic_putw (slot, MEM_STOP_ADDR(window), 0); - pcic_putw (slot, MEM_OFFSET(window), 0); -} - -/* - * map a range of addresses into system i/o space - * (no translation of i/o addresses is possible) - * - * 'width' is: - * + 0 to tell the PCIC to generate the ISA IOCS16* signal from - * the PCMCIA IOIS16* signal. - * + 1 to select 8-bit width - * + 2 to select 16-bit width - */ - -void -pcic_map_io (int slot, int window, unsigned short base, unsigned short length, - unsigned short width) -{ - unsigned char x; - - pcic_putw (slot, IO_START_ADDR(window), base); - pcic_putw (slot, IO_STOP_ADDR(window), base+length-1); - /* - * select the bits that determine whether - * an i/o operation is 8 or 16 bits wide - */ - x = pcic_getb (slot, PCIC_IOCTL); - switch (width) { - case 0: /* PCMCIA card decides */ - if (window) - x = (x & 0xf0) | PCIC_IO1_CS16; - else - x = (x & 0x0f) | PCIC_IO0_CS16; - break; - case 1: /* 8 bits wide */ - break; - case 2: /* 16 bits wide */ - if (window) - x = (x & 0xf0) | PCIC_IO1_16BIT; - else - x = (x & 0x0f) | PCIC_IO0_16BIT; - break; - } - pcic_putb (slot, PCIC_IOCTL, x); - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) | IO_ENABLE_BIT(window)); -} - -#ifdef TEST -void -pcic_unmap_io (int slot, int window) -{ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) & ~IO_ENABLE_BIT(window)); - pcic_putw (slot, IO_START_ADDR(window), 0); - pcic_putw (slot, IO_STOP_ADDR(window), 0); -} -#endif /* TEST */ - -/* - * tell the PCIC which irq we want to use. only the following are legal: - * 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 - * - * NB: 'irq' is an interrupt NUMBER, not a MASK as in struct isa_device. - */ - -void -pcic_map_irq (int slot, int irq) -{ - if (irq < 3 || irq == 6 || irq == 8 || irq == 13 || irq > 15) { - printf ("zp: pcic_map_irq (slot %d): illegal irq %d\n", slot, irq); - return; - } - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) | (irq & 0x0F)); -} - -void -pcic_power_on (int slot) -{ - pcic_putb (slot, PCIC_STATUS, - pcic_getb (slot, PCIC_STATUS) | PCIC_POW); - DELAY (100000); - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) | PCIC_DISRST | PCIC_PCPWRE); - DELAY (100000); - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) | PCIC_OUTENA); -} - -void -pcic_power_off (int slot) -{ - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) & ~(PCIC_OUTENA|PCIC_PCPWRE)); -} - -void -pcic_reset (int slot) -{ - /* assert RESET (by clearing a bit!), wait a bit, and de-assert it */ - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) & ~PCIC_CARDRESET); - DELAY (100000); - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) | PCIC_CARDRESET); -} - diff --git a/sys/pc98/pc98/scd.c b/sys/pc98/pc98/scd.c deleted file mode 100644 index fa29cc9dbb36..000000000000 --- a/sys/pc98/pc98/scd.c +++ /dev/null @@ -1,1556 +0,0 @@ -/*- - * Copyright (c) 1995 Mikael Hybsch - * All rights reserved. - * - * Portions of this file are copied from mcd.c - * which has the following copyrights: - * - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * Changes Copyright 1993 by Gary Clark II - * Changes Copyright (C) 1994 by Andrew A. Chernov - * - * Rewrote probe routine to work on newer Mitsumi drives. - * Additional changes (C) 1994 by Jordan K. Hubbard - * - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - */ - - -/* $Id: scd.c,v 1.4 1996/08/31 15:07:16 asami Exp $ */ - -/* Please send any comments to micke@dynas.se */ - -#define SCD_DEBUG 0 - -#include "scd.h" -#if NSCD > 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef DEVFS -#include -#endif /*DEVFS*/ - -#include -#include - -#include -#include - - -#define scd_part(dev) ((minor(dev)) & 7) -#define scd_unit(dev) (((minor(dev)) & 0x38) >> 3) -#define scd_phys(dev) (((minor(dev)) & 0x40) >> 6) -#define RAW_PART 2 - -/* flags */ -#define SCDOPEN 0x0001 /* device opened */ -#define SCDVALID 0x0002 /* parameters loaded */ -#define SCDINIT 0x0004 /* device is init'd */ -#define SCDPROBING 0x0020 /* probing */ -#define SCDTOC 0x0100 /* already read toc */ -#define SCDMBXBSY 0x0200 /* local mbx is busy */ -#define SCDSPINNING 0x0400 /* drive is spun up */ - -#define SCD_S_BEGIN 0 -#define SCD_S_BEGIN1 1 -#define SCD_S_WAITSTAT 2 -#define SCD_S_WAITFIFO 3 -#define SCD_S_WAITSPIN 4 -#define SCD_S_WAITREAD 5 -#define SCD_S_WAITPARAM 6 - -#define RDELAY_WAIT 300 -#define RDELAY_WAITREAD 300 - -#define SCDBLKSIZE 2048 - -#ifdef SCD_DEBUG - static int scd_debuglevel = SCD_DEBUG; -# define XDEBUG(level, data) {if (scd_debuglevel >= level) printf data;} -#else -# define XDEBUG(level, data) -#endif - -struct scd_mbx { - short unit; - short port; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; -}; - -static struct scd_data { - int iobase; - char double_speed; - char *name; - short flags; - int blksize; - u_long disksize; - struct disklabel dlabel; - int openflag; - struct { - unsigned char adr :4; - unsigned char ctl :4; /* xcdplayer needs this */ - unsigned char start_msf[3]; - } toc[MAX_TRACKS]; - short first_track; - short last_track; - struct ioc_play_msf last_play; - - short audio_status; - struct buf_queue_head head; /* head of buf queue */ - struct scd_mbx mbx; -#ifdef DEVFS - void *ra_devfs_token; - void *rc_devfs_token; - void *a_devfs_token; - void *c_devfs_token; -#endif -} scd_data[NSCD]; - -/* prototypes */ -static void hsg2msf(int hsg, bcd_t *msf); -static int msf2hsg(bcd_t *msf); - -static void process_attention(unsigned unit); -static inline void write_control(unsigned port, unsigned data); -static int waitfor_status_bits(int unit, int bits_set, int bits_clear); -static int send_cmd(u_int unit, u_char cmd, u_int nargs, ...); -static void init_drive(unsigned unit); -static int spin_up(unsigned unit); -static int read_toc(dev_t dev); -static int get_result(u_int unit, int result_len, u_char *result); -static void print_error(int unit, int errcode); - -static void scd_start(int unit); -static void scd_doread(int state, struct scd_mbx *mbxin); - -static int scd_eject(int unit); -static int scd_stop(int unit); -static int scd_pause(int unit); -static int scd_resume(int unit); -static int scd_playtracks(int unit, struct ioc_play_track *pt); -static int scd_playmsf(int unit, struct ioc_play_msf *msf); -static int scd_play(int unit, struct ioc_play_msf *msf); -static int scd_subchan(int unit, struct ioc_read_subchannel *sc); -static int read_subcode(int unit, struct sony_subchannel_position_data *sc); - -/* for xcdplayer */ -static int scd_toc_header(int unit, struct ioc_toc_header *th); -static int scd_toc_entrys(int unit, struct ioc_read_toc_entry *te); -#define SCD_LASTPLUS1 170 /* don't ask, xcdplayer passes this in */ - -static int scd_probe(struct isa_device *dev); -static int scd_attach(struct isa_device *dev); -struct isa_driver scddriver = { scd_probe, scd_attach, "scd" }; - -static d_open_t scdopen; -static d_close_t scdclose; -static d_ioctl_t scdioctl; -static d_strategy_t scdstrategy; - -#define CDEV_MAJOR 45 -#define BDEV_MAJOR 16 -static struct cdevsw scd_cdevsw; -static struct bdevsw scd_bdevsw = - { scdopen, scdclose, scdstrategy, scdioctl, /*16*/ - nodump, nopsize, 0, "scd", &scd_cdevsw, -1 }; - -static struct kern_devconf kdc_scd[NSCD] = { { - 0, 0, 0, /* filled in by dev_attach */ - "scd", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_UNCONFIGURED, /* status */ - "Sony CD-ROM drive", /* properly filled later */ - DC_CLS_RDISK /* class */ -} }; - -static inline void -scd_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_scd[id->id_unit] = kdc_scd[0]; - kdc_scd[id->id_unit].kdc_unit = id->id_unit; - kdc_scd[id->id_unit].kdc_isa = id; - dev_attach(&kdc_scd[id->id_unit]); -} - -int scd_attach(struct isa_device *dev) -{ - int unit = dev->id_unit; - struct scd_data *cd = scd_data + unit; - - cd->iobase = dev->id_iobase; /* Already set by probe, but ... */ - - kdc_scd[dev->id_unit].kdc_state = DC_IDLE; - /* name filled in probe */ - kdc_scd[dev->id_unit].kdc_description = scd_data[dev->id_unit].name; - printf("scd%d: <%s>\n", dev->id_unit, scd_data[dev->id_unit].name); - - init_drive(dev->id_unit); - - cd->flags = SCDINIT; - cd->audio_status = CD_AS_AUDIO_INVALID; - TAILQ_INIT(&cd->head); - -#ifdef DEVFS - cd->ra_devfs_token = - devfs_add_devswf(&scd_cdevsw, dkmakeminor(unit, 0, 0), - DV_CHR, UID_ROOT, GID_OPERATOR, 0640, - "rscd%da", unit); - cd->rc_devfs_token = - devfs_add_devswf(&scd_cdevsw, dkmakeminor(unit, 0, RAW_PART), - DV_CHR, UID_ROOT, GID_OPERATOR, 0640, - "rscd%dc", unit); - cd->a_devfs_token = - devfs_add_devswf(&scd_bdevsw, dkmakeminor(unit, 0, 0), - DV_BLK, UID_ROOT, GID_OPERATOR, 0640, - "scd%da", unit); - cd->c_devfs_token = - devfs_add_devswf(&scd_bdevsw, dkmakeminor(unit, 0, RAW_PART), - DV_BLK, UID_ROOT, GID_OPERATOR, 0640, - "scd%dc", unit); -#endif - return 1; -} - -static int -scdopen(dev_t dev, int flags, int fmt, struct proc *p) -{ - int unit,part,phys; - int rc; - struct scd_data *cd; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - /* not initialized*/ - if (!(cd->flags & SCDINIT)) - return ENXIO; - - /* invalidated in the meantime? mark all open part's invalid */ - if (cd->openflag) - return ENXIO; - - XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS))); - - if ((rc = spin_up(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - if (!(cd->flags & SCDTOC)) { - int loop_count = 3; - - while (loop_count-- > 0 && (rc = read_toc(dev)) != 0) { - if (rc == ERR_NOT_SPINNING) { - rc = spin_up(unit); - if (rc) { - print_error(unit, rc);\ - return EIO; - } - continue; - } - printf("scd%d: TOC read error 0x%x\n", unit, rc); - return EIO; - } - } - - cd->openflag = 1; - cd->flags |= SCDVALID; - kdc_scd[unit].kdc_state = DC_BUSY; - - return 0; -} - -static int -scdclose(dev_t dev, int flags, int fmt, struct proc *p) -{ - int unit,part,phys; - struct scd_data *cd; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - if (!(cd->flags & SCDINIT) || !cd->openflag) - return ENXIO; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) { - (void)send_cmd(unit, CMD_SPIN_DOWN, 0); - cd->flags &= ~SCDSPINNING; - } - - kdc_scd[unit].kdc_state = DC_IDLE; - - /* close channel */ - cd->openflag = 0; - - return 0; -} - -static void -scdstrategy(struct buf *bp) -{ - struct scd_data *cd; - int s; - int unit = scd_unit(bp->b_dev); - - cd = scd_data + unit; - - XDEBUG(2, ("scd%d: DEBUG: strategy: block=%ld, bcount=%ld\n", unit, bp->b_blkno, bp->b_bcount)); - - if (unit >= NSCD || bp->b_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) { - printf("scd%d: strategy failure: blkno = %ld, bcount = %ld\n", - unit, bp->b_blkno, bp->b_bcount); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - - /* if device invalidated (e.g. media change, door open), error */ - if (!(cd->flags & SCDVALID)) { - printf("scd%d: media changed\n", unit); - bp->b_error = EIO; - goto bad; - } - - /* read only */ - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - /* no data to read */ - if (bp->b_bcount == 0) - goto done; - - if (!(cd->flags & SCDTOC)) { - bp->b_error = EIO; - goto bad; - } - /* adjust transfer if necessary */ - if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) - goto done; - - bp->b_pblkno = bp->b_blkno; - bp->b_resid = 0; - - /* queue it */ - s = splbio(); - tqdisksort(&cd->head, bp); - splx(s); - - /* now check whether we can perform processing */ - scd_start(unit); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - biodone(bp); - return; -} - -static void -scd_start(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct buf *bp; - struct partition *p; - register s = splbio(); - - if (cd->flags & SCDMBXBSY) { - splx(s); - return; - } - - bp = TAILQ_FIRST(&cd->head); - if (bp != 0) { - /* block found to process, dequeue */ - TAILQ_REMOVE(&cd->head, bp, b_act); - cd->flags |= SCDMBXBSY; - splx(s); - } else { - /* nothing to do */ - splx(s); - return; - } - - p = cd->dlabel.d_partitions + scd_part(bp->b_dev); - - cd->mbx.unit = unit; - cd->mbx.port = cd->iobase; - cd->mbx.retry = 3; - cd->mbx.bp = bp; - cd->mbx.p_offset = p->p_offset; - splx(s); - - scd_doread(SCD_S_BEGIN,&(cd->mbx)); - return; -} - -static int -scdioctl(dev_t dev, int cmd, caddr_t addr, int flags, struct proc *p) -{ - struct scd_data *cd; - int unit,part; - - unit = scd_unit(dev); - part = scd_part(dev); - cd = scd_data + unit; - - XDEBUG(1, ("scd%d: ioctl: cmd=0x%x\n", unit, cmd)); - - if (!(cd->flags & SCDVALID)) - return EIO; - - switch (cmd) { - case DIOCSBAD: - return EINVAL; - case DIOCGDINFO: - *(struct disklabel *)addr = cd->dlabel; - return 0; - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &cd->dlabel; - ((struct partinfo *)addr)->part = - &cd->dlabel.d_partitions[0]; - return 0; - case CDIOCPLAYTRACKS: - return scd_playtracks(unit, (struct ioc_play_track *) addr); - case CDIOCPLAYBLOCKS: - return EINVAL; - case CDIOCPLAYMSF: - return scd_playmsf(unit, (struct ioc_play_msf *) addr); - case CDIOCREADSUBCHANNEL: - return scd_subchan(unit, (struct ioc_read_subchannel *) addr); - case CDIOREADTOCHEADER: - return scd_toc_header (unit, (struct ioc_toc_header *) addr); - case CDIOREADTOCENTRYS: - return scd_toc_entrys (unit, (struct ioc_read_toc_entry*) addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTERIO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return scd_resume(unit); - case CDIOCPAUSE: - return scd_pause(unit); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return scd_stop(unit); - case CDIOCEJECT: - return scd_eject(unit); - case CDIOCALLOW: - return 0; - case CDIOCSETDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel++; -#endif - return 0; - case CDIOCCLRDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel = 0; - -#endif - return 0; - default: - printf("scd%d: unsupported ioctl (cmd=0x%x)\n", unit, cmd); - return ENOTTY; - } -} - -/*************************************************************** - * lower level of driver starts here - **************************************************************/ - -static int -scd_playtracks(int unit, struct ioc_play_track *pt) -{ - struct scd_data *cd = scd_data + unit; - struct ioc_play_msf msf; - int a = pt->start_track; - int z = pt->end_track; - int rc; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - if (rc == -ERR_NOT_SPINNING) { - if (spin_up(unit) != 0) - return EIO; - rc = read_toc(unit); - } - if (rc != 0) { - print_error(unit, rc); - return EIO; - } - } - - XDEBUG(1, ("scd%d: playtracks from %d:%d to %d:%d\n", unit, - a, pt->start_index, z, pt->end_index)); - - if ( a < cd->first_track - || a > cd->last_track - || a > z - || z > cd->last_track) - return EINVAL; - - bcopy(cd->toc[a].start_msf, &msf.start_m, 3); - hsg2msf(msf2hsg(cd->toc[z+1].start_msf)-1, &msf.end_m); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bin format */ -static int -scd_playmsf(int unit, struct ioc_play_msf *msfin) -{ - struct ioc_play_msf msf; - - msf.start_m = bin2bcd(msfin->start_m); - msf.start_s = bin2bcd(msfin->start_s); - msf.start_f = bin2bcd(msfin->start_f); - msf.end_m = bin2bcd(msfin->end_m); - msf.end_s = bin2bcd(msfin->end_s); - msf.end_f = bin2bcd(msfin->end_f); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bcd format */ -static int -scd_play(int unit, struct ioc_play_msf *msf) -{ - struct scd_data *cd = scd_data + unit; - int i, rc; - - XDEBUG(1, ("scd%d: playing: %02x:%02x:%02x -> %02x:%02x:%02x\n", unit, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f)); - - for (i = 0; i < 2; i++) { - rc = send_cmd(unit, CMD_PLAY_AUDIO, 7, - 0x03, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f); - if (rc == -ERR_NOT_SPINNING) { - cd->flags &= ~SCDSPINNING; - if (spin_up(unit) != 0) - return EIO; - } else if (rc < 0) { - print_error(unit, rc); - return EIO; - } else { - break; - } - } - cd->audio_status = CD_AS_PLAY_IN_PROGRESS; - bcopy((char *)msf, (char *)&cd->last_play, sizeof(struct ioc_play_msf)); - return 0; -} - -static int -scd_stop(int unit) -{ - struct scd_data *cd = scd_data + unit; - - (void)send_cmd(unit, CMD_STOP_AUDIO, 0); - cd->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -static int -scd_pause(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data subpos; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) - return EINVAL; - - if (read_subcode(unit, &subpos) != 0) - return EIO; - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0) - return EIO; - - cd->last_play.start_m = subpos.abs_msf[0]; - cd->last_play.start_s = subpos.abs_msf[1]; - cd->last_play.start_f = subpos.abs_msf[2]; - cd->audio_status = CD_AS_PLAY_PAUSED; - - XDEBUG(1, ("scd%d: pause @ %02x:%02x:%02x\n", unit, - cd->last_play.start_m, - cd->last_play.start_s, - cd->last_play.start_f)); - - return 0; -} - -static int -scd_resume(int unit) -{ - if (scd_data[unit].audio_status != CD_AS_PLAY_PAUSED) - return EINVAL; - return scd_play(unit, &scd_data[unit].last_play); -} - -static int -scd_eject(int unit) -{ - struct scd_data *cd = scd_data + unit; - - cd->audio_status = CD_AS_AUDIO_INVALID; - cd->flags &= ~(SCDSPINNING|SCDTOC); - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0 || - send_cmd(unit, CMD_SPIN_DOWN, 0) != 0 || - send_cmd(unit, CMD_EJECT, 0) != 0) - { - return EIO; - } - return 0; -} - -static int -scd_subchan(int unit, struct ioc_read_subchannel *sc) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data q; - struct cd_sub_channel_info data; - - XDEBUG(1, ("scd%d: subchan af=%d, df=%d\n", unit, - sc->address_format, - sc->data_format)); - - if (sc->address_format != CD_MSF_FORMAT) - return EINVAL; - - if (sc->data_format != CD_CURRENT_POSITION) - return EINVAL; - - if (read_subcode(unit, &q) != 0) - return EIO; - - data.header.audio_status = cd->audio_status; - data.what.position.data_format = CD_MSF_FORMAT; - data.what.position.track_number = bcd2bin(q.track_number); - data.what.position.reladdr.msf.unused = 0; - data.what.position.reladdr.msf.minute = bcd2bin(q.rel_msf[0]); - data.what.position.reladdr.msf.second = bcd2bin(q.rel_msf[1]); - data.what.position.reladdr.msf.frame = bcd2bin(q.rel_msf[2]); - data.what.position.absaddr.msf.unused = 0; - data.what.position.absaddr.msf.minute = bcd2bin(q.abs_msf[0]); - data.what.position.absaddr.msf.second = bcd2bin(q.abs_msf[1]); - data.what.position.absaddr.msf.frame = bcd2bin(q.abs_msf[2]); - - if (copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len))!=0) - return EFAULT; - return 0; -} - -int -scd_probe(struct isa_device *dev) -{ - struct sony_drive_configuration drive_config; - int unit = dev->id_unit; - int rc; - static char namebuf[8+16+8+3]; - char *s = namebuf; - int loop_count = 0; - - scd_data[unit].flags = SCDPROBING; - scd_data[unit].iobase = dev->id_iobase; - - bzero(&drive_config, sizeof(drive_config)); - - scd_registerdev(dev); - -again: - /* Reset drive */ - write_control(dev->id_iobase, CBIT_RESET_DRIVE); - - /* Calm down */ - DELAY(300000); - - /* Only the ATTENTION bit may be set */ - if ((inb(dev->id_iobase+IREG_STATUS) & ~1) != 0) { - XDEBUG(1, ("scd: too many bits set. probe failed.\n")); - return 0; - } - rc = send_cmd(unit, CMD_GET_DRIVE_CONFIG, 0); - if (rc != sizeof(drive_config)) { - /* Sometimes if the drive is playing audio I get */ - /* the bad result 82. Fix by repeating the reset */ - if (rc > 0 && loop_count++ == 0) - goto again; - return 0; - } - if (get_result(unit, rc, (u_char *)&drive_config) != 0) - return 0; - - bcopy(drive_config.vendor, namebuf, 8); - s = namebuf+8; - while (*(s-1) == ' ') /* Strip trailing spaces */ - s--; - *s++ = ' '; - bcopy(drive_config.product, s, 16); - s += 16; - while (*(s-1) == ' ') - s--; - *s++ = ' '; - bcopy(drive_config.revision, s, 8); - s += 8; - while (*(s-1) == ' ') - s--; - *s = 0; - - scd_data[unit].name = namebuf; - - if (drive_config.config & 0x10) - scd_data[unit].double_speed = 1; - else - scd_data[unit].double_speed = 0; - - return 4; -} - -static int -read_subcode(int unit, struct sony_subchannel_position_data *sc) -{ - int rc; - - rc = send_cmd(unit, CMD_GET_SUBCHANNEL_DATA, 0); - if (rc < 0 || rc < sizeof(*sc)) - return EIO; - if (get_result(unit, rc, (u_char *)sc) != 0) - return EIO; - return 0; -} - -/* State machine copied from mcd.c */ - -/* This (and the code in mcd.c) will not work with more than one drive */ -/* because there is only one mbxsave below. Should fix that some day. */ -/* (mbxsave & state should probably be included in the scd_data struct and */ -/* the unit number used as first argument to scd_doread().) /Micke */ - -/* state machine to process read requests - * initialize with SCD_S_BEGIN: reset state machine - * SCD_S_WAITSTAT: wait for ready (!busy) - * SCD_S_WAITSPIN: wait for drive to spin up (if not spinning) - * SCD_S_WAITFIFO: wait for param fifo to get ready, them exec. command. - * SCD_S_WAITREAD: wait for data ready, read data - * SCD_S_WAITPARAM: wait for command result params, read them, error if bad data read. - */ - -static struct scd_mbx *mbxsave; - -static void -scd_doread(int state, struct scd_mbx *mbxin) -{ - struct scd_mbx *mbx = (state!=SCD_S_BEGIN) ? mbxsave : mbxin; - int unit = mbx->unit; - int port = mbx->port; - struct buf *bp = mbx->bp; - struct scd_data *cd = scd_data + unit; - int reg,i; - int blknum; - caddr_t addr; - static char sdata[3]; /* Must be preserved between calls to this function */ - -loop: - switch (state) { - case SCD_S_BEGIN: - mbx = mbxsave = mbxin; - - case SCD_S_BEGIN1: - /* get status */ - mbx->count = RDELAY_WAIT; - - process_attention(unit); - goto trystat; - - case SCD_S_WAITSTAT: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSTAT); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. drive busy.\n",unit); - goto harderr; - } - -trystat: - if (IS_BUSY(port)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */ - return; - } - - process_attention(unit); - - /* reject, if audio active */ - if (cd->audio_status & CD_AS_PLAY_IN_PROGRESS) { - printf("scd%d: audio is active\n",unit); - goto harderr; - } - - mbx->sz = cd->blksize; - - /* for first block */ - mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz; - mbx->skip = 0; - -nextblock: - if (!(cd->flags & SCDVALID)) - goto changed; - - blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE)) - + mbx->p_offset + mbx->skip/mbx->sz; - - XDEBUG(2, ("scd%d: scd_doread: read blknum=%d\n", unit, blknum)); - - /* build parameter block */ - hsg2msf(blknum, sdata); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - write_control(port, CBIT_DATA_READY_CLEAR); - - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - goto writeparam; - - mbx->count = 100; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - - case SCD_S_WAITSPIN: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSPIN); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for drive to spin up.\n", unit); - goto harderr; - } - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x20: - i = inb(port+IREG_RESULT); - print_error(unit, i); - goto harderr; - case 0x00: - (void)inb(port+IREG_RESULT); - cd->flags |= SCDSPINNING; - break; - } - XDEBUG(1, ("scd%d: DEBUG: spin up complete\n", unit)); - - state = SCD_S_BEGIN1; - goto loop; - - case SCD_S_WAITFIFO: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITFIFO); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. write param not ready.\n",unit); - goto harderr; - } - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - } - XDEBUG(1, ("scd%d: mbx->count (writeparamwait) = %d(%d)\n", unit, mbx->count, 100)); - -writeparam: - /* The reason this test isn't done 'till now is to make sure */ - /* that it is ok to send the SPIN_UP cmd below. */ - if (!(cd->flags & SCDSPINNING)) { - XDEBUG(1, ("scd%d: spinning up drive ...\n", unit)); - outb(port+OREG_COMMAND, CMD_SPIN_UP); - mbx->count = 300; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - - reg = port + OREG_WPARAMS; - /* send the read command */ - disable_intr(); - outb(reg, sdata[0]); - outb(reg, sdata[1]); - outb(reg, sdata[2]); - outb(reg, 0); - outb(reg, 0); - outb(reg, 1); - outb(port+OREG_COMMAND, CMD_READ); - enable_intr(); - - mbx->count = RDELAY_WAITREAD; - for (i = 0; i < 50; i++) { - if (STATUS_BIT(port, SBIT_DATA_READY)) - goto got_data; - DELAY(100); - } - - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - - case SCD_S_WAITREAD: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITREAD); - if (mbx->count-- <= 0) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto got_param; - printf("scd%d: timeout while reading data\n",unit); - goto readerr; - } - if (!STATUS_BIT(port, SBIT_DATA_READY)) { - process_attention(unit); - if (!(cd->flags & SCDVALID)) - goto changed; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - } - XDEBUG(2, ("scd%d: mbx->count (after RDY_BIT) = %d(%d)\n", unit, mbx->count, RDELAY_WAITREAD)); - -got_data: - /* data is ready */ - addr = bp->b_un.b_addr + mbx->skip; - write_control(port, CBIT_DATA_READY_CLEAR); - insb(port+IREG_DATA, addr, mbx->sz); - - mbx->count = 100; - for (i = 0; i < 20; i++) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto waitfor_param; - DELAY(100); - } - goto waitfor_param; - - case SCD_S_WAITPARAM: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITPARAM); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for params\n",unit); - goto readerr; - } - -waitfor_param: - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */ - return; - } -#if SCD_DEBUG - if (mbx->count < 100 && scd_debuglevel > 0) - printf("scd%d: mbx->count (paramwait) = %d(%d)\n", unit, mbx->count, 100); -#endif - -got_param: - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x50: - switch (i) { - case ERR_FATAL_READ_ERROR1: - case ERR_FATAL_READ_ERROR2: - printf("scd%d: unrecoverable read error 0x%x\n", unit, i); - goto harderr; - } - break; - case 0x20: - i = inb(port+IREG_RESULT); - switch (i) { - case ERR_NOT_SPINNING: - XDEBUG(1, ("scd%d: read error: drive not spinning\n", unit)); - if (mbx->retry-- > 0) { - state = SCD_S_BEGIN1; - cd->flags &= ~SCDSPINNING; - goto loop; - } - goto harderr; - default: - print_error(unit, i); - goto readerr; - } - case 0x00: - i = inb(port+IREG_RESULT); - break; - } - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; - } - - /* return buffer */ - bp->b_resid = 0; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - } - -readerr: - if (mbx->retry-- > 0) { - printf("scd%d: retrying ...\n",unit); - state = SCD_S_BEGIN1; - goto loop; - } -harderr: - /* invalidate the buffer */ - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - -changed: - printf("scd%d: media changed\n", unit); - goto harderr; -} - -static void -hsg2msf(int hsg, bcd_t *msf) -{ - hsg += 150; - M_msf(msf) = bin2bcd(hsg / 4500); - hsg %= 4500; - S_msf(msf) = bin2bcd(hsg / 75); - F_msf(msf) = bin2bcd(hsg % 75); -} - -static int -msf2hsg(bcd_t *msf) -{ - return (bcd2bin(M_msf(msf)) * 60 + - bcd2bin(S_msf(msf))) * 75 + - bcd2bin(F_msf(msf)) - 150; -} - -static void -process_attention(unsigned unit) -{ - unsigned port = scd_data[unit].iobase; - unsigned char code; - int count = 0; - - while (IS_ATTENTION(port) && count++ < 30) { - write_control(port, CBIT_ATTENTION_CLEAR); - code = inb(port+IREG_RESULT); - -#if SCD_DEBUG - if (scd_debuglevel > 0) { - if (count == 1) - printf("scd%d: DEBUG: ATTENTIONS = 0x%x", unit, code); - else - printf(",0x%x", code); - } -#endif - - switch (code) { - case ATTEN_SPIN_DOWN: - scd_data[unit].flags &= ~SCDSPINNING; - break; - - case ATTEN_SPIN_UP_DONE: - scd_data[unit].flags |= SCDSPINNING; - break; - - case ATTEN_AUDIO_DONE: - scd_data[unit].audio_status = CD_AS_PLAY_COMPLETED; - break; - - case ATTEN_DRIVE_LOADED: - scd_data[unit].flags &= ~(SCDTOC|SCDSPINNING|SCDVALID); - scd_data[unit].audio_status = CD_AS_AUDIO_INVALID; - break; - - case ATTEN_EJECT_PUSHED: - scd_data[unit].flags &= ~SCDVALID; - break; - } - DELAY(100); - } -#if SCD_DEBUG - if (scd_debuglevel > 0 && count > 0) - printf("\n"); -#endif -} - -/* Returns 0 OR sony error code */ -static int -spin_up(unsigned unit) -{ - unsigned char res_reg[12]; - unsigned int res_size; - int rc; - int loop_count = 0; - -again: - rc = send_cmd(unit, CMD_SPIN_UP, 0, 0, res_reg, &res_size); - if (rc != 0) { - XDEBUG(2, ("scd%d: CMD_SPIN_UP error 0x%x\n", unit, rc)); - return rc; - } - - if (!(scd_data[unit].flags & SCDTOC)) { - rc = send_cmd(unit, CMD_READ_TOC, 0); - if (rc == ERR_NOT_SPINNING) { - if (loop_count++ < 3) - goto again; - return rc; - } - if (rc != 0) - return rc; - } - - scd_data[unit].flags |= SCDSPINNING; - - return 0; -} - -static struct sony_tracklist * -get_tl(struct sony_toc *toc, int size) -{ - struct sony_tracklist *tl = &toc->tracks[0]; - - if (tl->track != 0xb0) - return tl; - (char *)tl += 9; - if (tl->track != 0xb1) - return tl; - (char *)tl += 9; - if (tl->track != 0xb2) - return tl; - (char *)tl += 9; - if (tl->track != 0xb3) - return tl; - (char *)tl += 9; - if (tl->track != 0xb4) - return tl; - (char *)tl += 9; - if (tl->track != 0xc0) - return tl; - (char *)tl += 9; - return tl; -} - -static int -read_toc(dev_t dev) -{ - unsigned unit; - struct scd_data *cd; - unsigned part = 0; /* For now ... */ - struct sony_toc toc; - struct sony_tracklist *tl; - int rc, i, j; - u_long first, last; - - unit = scd_unit(dev); - cd = scd_data + unit; - - rc = send_cmd(unit, CMD_GET_TOC, 1, part+1); - if (rc < 0) - return rc; - if (rc > sizeof(toc)) { - printf("scd%d: program error: toc too large (%d)\n", unit, rc); - return EIO; - } - if (get_result(unit, rc, (u_char *)&toc) != 0) - return EIO; - - XDEBUG(1, ("scd%d: toc read. len = %d, sizeof(toc) = %d\n", unit, rc, sizeof(toc))); - - tl = get_tl(&toc, rc); - first = msf2hsg(tl->start_msf); - last = msf2hsg(toc.lead_out_start_msf); - cd->blksize = SCDBLKSIZE; - cd->disksize = last*cd->blksize/DEV_BSIZE; - - XDEBUG(1, ("scd%d: firstsector = %ld, lastsector = %ld", unit, - first, last)); - - cd->first_track = bcd2bin(toc.first_track); - cd->last_track = bcd2bin(toc.last_track); - if (cd->last_track > (MAX_TRACKS-2)) - cd->last_track = MAX_TRACKS-2; - for (j = 0, i = cd->first_track; i <= cd->last_track; i++, j++) { - cd->toc[i].adr = tl[j].adr; - cd->toc[i].ctl = tl[j].ctl; /* for xcdplayer */ - bcopy(tl[j].start_msf, cd->toc[i].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - if ((j % 3) == 0) - printf("\nscd%d: tracks ", unit); - printf("[%03d: %2d %2d %2d] ", i, - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - } - bcopy(toc.lead_out_start_msf, cd->toc[cd->last_track+1].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - i = cd->last_track+1; - printf("[END: %2d %2d %2d]\n", - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - - bzero(&cd->dlabel,sizeof(struct disklabel)); - /* filled with spaces first */ - strncpy(cd->dlabel.d_typename," ", - sizeof(cd->dlabel.d_typename)); - strncpy(cd->dlabel.d_typename, cd->name, - min(strlen(cd->name), sizeof(cd->dlabel.d_typename) - 1)); - strncpy(cd->dlabel.d_packname,"unknown ", - sizeof(cd->dlabel.d_packname)); - cd->dlabel.d_secsize = cd->blksize; - cd->dlabel.d_nsectors = 100; - cd->dlabel.d_ntracks = 1; - cd->dlabel.d_ncylinders = (cd->disksize/100)+1; - cd->dlabel.d_secpercyl = 100; - cd->dlabel.d_secperunit = cd->disksize; - cd->dlabel.d_rpm = 300; - cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; - cd->dlabel.d_npartitions= 1; - cd->dlabel.d_partitions[0].p_offset = 0; - cd->dlabel.d_partitions[0].p_size = cd->disksize; - cd->dlabel.d_partitions[0].p_fstype = 9; - cd->dlabel.d_magic = DISKMAGIC; - cd->dlabel.d_magic2 = DISKMAGIC; - cd->dlabel.d_checksum = dkcksum(&cd->dlabel); - - cd->flags |= SCDTOC; - - return 0; -} - -static inline void -write_control(unsigned port, unsigned data) -{ - outb(port + OREG_CONTROL, data); -} - -static void -init_drive(unsigned unit) -{ - int rc; - - rc = send_cmd(unit, CMD_SET_DRIVE_PARAM, 2, - 0x05, 0x03 | ((scd_data[unit].double_speed) ? 0x04: 0)); - if (rc != 0) - printf("scd%d: Unable to set parameters. Errcode = 0x%x\n", unit, rc); -} - -/* Returns 0 or errno */ -static int -get_result(u_int unit, int result_len, u_char *result) -{ - unsigned int port = scd_data[unit].iobase; - unsigned int res_reg = port + IREG_RESULT; - int loop_index = 2; /* send_cmd() reads two bytes ... */ - - XDEBUG(1, ("scd%d: DEBUG: get_result: bytes=%d\n", unit, result_len)); - - while (result_len-- > 0) { - if (loop_index++ >= 10) { - loop_index = 1; - if (waitfor_status_bits(unit, SBIT_RESULT_READY, 0)) - return EIO; - write_control(port, CBIT_RESULT_READY_CLEAR); - } - if (result) - *result++ = inb(res_reg); - else - (void)inb(res_reg); - } - return 0; -} - -/* Returns -0x100 for timeout, -(drive error code) OR number of result bytes */ -static int -send_cmd(u_int unit, u_char cmd, u_int nargs, ...) -{ - va_list ap; - u_int port = scd_data[unit].iobase; - u_int reg; - u_char c; - int rc; - int i; - - if (waitfor_status_bits(unit, 0, SBIT_BUSY)) { - printf("scd%d: drive busy\n", unit); - return -0x100; - } - - XDEBUG(1,("scd%d: DEBUG: send_cmd: cmd=0x%x nargs=%d", unit, cmd, nargs)); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - - for (i = 0; i < 100; i++) - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - break; - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - XDEBUG(1, ("\nscd%d: wparam timeout\n", unit)); - return -EIO; - } - - va_start(ap, nargs); - reg = port + OREG_WPARAMS; - for (i = 0; i < nargs; i++) { - c = (u_char)va_arg(ap, int); - outb(reg, c); - XDEBUG(1, (",{0x%x}", c)); - } - va_end(ap); - XDEBUG(1, ("\n")); - - outb(port+OREG_COMMAND, cmd); - - rc = waitfor_status_bits(unit, SBIT_RESULT_READY, SBIT_BUSY); - if (rc) - return -0x100; - - reg = port + IREG_RESULT; - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((rc = inb(reg)) & 0xf0) { - case 0x20: - rc = inb(reg); - /* FALL TROUGH */ - case 0x50: - XDEBUG(1, ("scd%d: DEBUG: send_cmd: drive_error=0x%x\n", unit, rc)); - return -rc; - case 0x00: - default: - rc = inb(reg); - XDEBUG(1, ("scd%d: DEBUG: send_cmd: result_len=%d\n", unit, rc)); - return rc; - } -} - -static void -print_error(int unit, int errcode) -{ - switch (errcode) { - case -ERR_CD_NOT_LOADED: - printf("scd%d: door is open\n", unit); - break; - case -ERR_NO_CD_INSIDE: - printf("scd%d: no cd inside\n", unit); - break; - default: - if (errcode == -0x100 || errcode > 0) - printf("scd%d: device timeout\n", unit); - else - printf("scd%d: unexpected error 0x%x\n", unit, -errcode); - break; - } -} - -/* Returns 0 or errno value */ -static int -waitfor_status_bits(int unit, int bits_set, int bits_clear) -{ - u_int port = scd_data[unit].iobase; - u_int flags = scd_data[unit].flags; - u_int reg = port + IREG_STATUS; - u_int max_loop; - u_char c = 0; - - if (flags & SCDPROBING) { - max_loop = 0; - while (max_loop++ < 1000) { - c = inb(reg); - if (c == 0xff) - return EIO; - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - DELAY(10000); - } - } else { - max_loop = 100; - while (max_loop-- > 0) { - c = inb(reg); - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - tsleep(waitfor_status_bits, PZERO - 1, "waitfor", hz/10); - } - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - return 0; - } -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) - printf("scd%d: DEBUG: waitfor: TIMEOUT (0x%x,(0x%x,0x%x))\n", unit, c, bits_set, bits_clear); - else -#endif - printf("scd%d: timeout.\n", unit); - return EIO; -} - -/* these two routines for xcdplayer - "borrowed" from mcd.c */ -static int -scd_toc_header (int unit, struct ioc_toc_header* th) -{ - struct scd_data *cd = scd_data + unit; - int rc; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - th->starting_track = cd->first_track; - th->ending_track = cd->last_track; - th->len = 0; /* not used */ - - return 0; -} - -static int -scd_toc_entrys (int unit, struct ioc_read_toc_entry *te) -{ - struct scd_data *cd = scd_data + unit; - struct cd_toc_entry toc_entry; - int rc, i, len = te->data_len; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - /* find the toc to copy*/ - i = te->starting_track; - if (i == SCD_LASTPLUS1) - i = cd->last_track + 1; - - /* verify starting track */ - if (i < cd->first_track || i > cd->last_track+1) - return EINVAL; - - /* valid length ? */ - if (len < sizeof(struct cd_toc_entry) - || (len % sizeof(struct cd_toc_entry)) != 0) - return EINVAL; - - /* copy the toc data */ - toc_entry.control = cd->toc[i].ctl; - toc_entry.addr_type = te->address_format; - toc_entry.track = i; - if (te->address_format == CD_MSF_FORMAT) { - toc_entry.addr.msf.unused = 0; - toc_entry.addr.msf.minute = bcd2bin(cd->toc[i].start_msf[0]); - toc_entry.addr.msf.second = bcd2bin(cd->toc[i].start_msf[1]); - toc_entry.addr.msf.frame = bcd2bin(cd->toc[i].start_msf[2]); - } - - /* copy the data back */ - if (copyout(&toc_entry, te->data, sizeof(struct cd_toc_entry)) != 0) - return EFAULT; - - return 0; -} - - -static scd_devsw_installed = 0; - -static void scd_drvinit(void *unused) -{ - - if( ! scd_devsw_installed ) { - bdevsw_add_generic(BDEV_MAJOR,CDEV_MAJOR, &scd_bdevsw); - scd_devsw_installed = 1; - } -} - -SYSINIT(scddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,scd_drvinit,NULL) - - -#endif /* NSCD > 0 */ diff --git a/sys/pc98/pc98/spkr.c b/sys/pc98/pc98/spkr.c index 3d78075b4227..611bd1677f9b 100644 --- a/sys/pc98/pc98/spkr.c +++ b/sys/pc98/pc98/spkr.c @@ -4,12 +4,12 @@ * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993 * modified for FreeBSD by Andrew A. Chernov * - * $Id: spkr.c,v 1.2 1996/07/23 07:46:39 asami Exp $ + * $Id: spkr.c,v 1.3 1996/08/30 10:43:09 asami Exp $ */ /* * modified for PC98 - * $Id: spkr.c,v 1.2 1996/07/23 07:46:39 asami Exp $ + * $Id: spkr.c,v 1.3 1996/08/30 10:43:09 asami Exp $ */ #include "speaker.h" @@ -26,7 +26,6 @@ #include #ifdef PC98 #include -#include #include #else #include diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c index bf9672b30d78..58fe8d9acd56 100644 --- a/sys/pc98/pc98/syscons.c +++ b/sys/pc98/pc98/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.4 1996/08/31 15:07:23 asami Exp $ + * $Id: syscons.c,v 1.5 1996/09/03 10:24:01 asami Exp $ */ #include "sc.h" @@ -88,6 +88,9 @@ #define MAXCONS 16 #endif +#define COLD 0 +#define WARM 1 +#define RUNNING 2 /* this may break on older VGA's but is usefull on real 32 bit systems */ #define bcopyw bcopy @@ -118,33 +121,33 @@ static void *sc_devfs_token[MAXCONS]; static scr_stat *new_scp, *old_scp; static term_stat kernel_console; static default_attr *current_default; -static char init_done = FALSE; -static int configuration = 0; +static int flags = 0; +static char init_done = COLD; static char switch_in_progress = FALSE; -static char blink_in_progress = FALSE; static char write_in_progress = FALSE; +static char blink_in_progress = FALSE; +static int blinkrate = 0; #ifndef PC98 u_int crtc_addr = MONO_BASE; #endif -static char crtc_vga = FALSE; + char crtc_vga = FALSE; static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0; #ifdef PC98 static u_char nlkcnt = 0, slkcnt = 0, alkcnt = 0; #else static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; #endif -static char *font_8 = NULL, *font_14 = NULL, *font_16 = NULL; -static int fonts_loaded = 0; - char palette[3*256]; + char *font_8 = NULL, *font_14 = NULL, *font_16 = NULL; + int fonts_loaded = 0; + char *palette; static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); static int delayed_next_scr = FALSE; static long scrn_blank_time = 0; /* screen saver timeout value */ int scrn_blanked = FALSE; /* screen saver active flag */ static long scrn_time_stamp; u_char scr_map[256]; -#ifndef PC98 -static char *video_mode_ptr = NULL; -#endif + u_char scr_rmap[256]; + char *video_mode_ptr = NULL; static char *cut_buffer; static u_short mouse_and_mask[16] = { 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, @@ -163,12 +166,12 @@ void (*current_saver) __P((int blank)) = none_saver; #ifdef not_yet_done #define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) +static const int nsccons = MAXCONS+1; struct tty *sccons[MAXCONS+1]; #else #define VIRTUAL_TTY(x) &sccons[x] #define CONSOLE_TTY &sccons[MAXCONS] static struct tty sccons[MAXCONS+1]; -static const int nsccons = MAXCONS+1; #endif #ifdef PC98 @@ -207,7 +210,8 @@ static int switch_scr(scr_stat *scp, u_int next_scr); static void exchange_scr(void); static inline void move_crsr(scr_stat *scp, int x, int y); static void scan_esc(scr_stat *scp, u_char c); -static inline void draw_cursor(scr_stat *scp, int show); +static void draw_cursor_image(scr_stat *scp); +static void remove_cursor_image(scr_stat *scp); static void ansi_put(scr_stat *scp, u_char *buf, int len); static u_char *get_fstr(u_int c, u_int *len); static void update_leds(int which); @@ -216,18 +220,18 @@ static int history_up_line(scr_stat *scp); static int history_down_line(scr_stat *scp); static void kbd_wait(void); static void kbd_cmd(u_char command); -static void set_mode(scr_stat *scp); static void set_vgaregs(char *modetable); static void set_font_mode(void); static void set_normal_mode(void); -static void copy_font(int operation, int font_type, char* font_image); -static void set_destructive_cursor(scr_stat *scp, int force); +static void set_destructive_cursor(scr_stat *scp); static void set_mouse_pos(scr_stat *scp); -static void reverse_mouse_cut(scr_stat *scp, int cut); static void mouse_cut_start(scr_stat *scp); static void mouse_cut_end(scr_stat *scp); static void mouse_paste(scr_stat *scp); static void draw_mouse_image(scr_stat *scp); +static void remove_mouse_image(scr_stat *scp); +static void draw_cutmarking(scr_stat *scp); +static void remove_cutmarking(scr_stat *scp); static void save_palette(void); static void do_bell(scr_stat *scp, int pitch, int duration); static void blink_screen(scr_stat *scp); @@ -315,87 +319,6 @@ mask2attr(struct term_stat *term) return attr; } -/* - * These functions need to be before calls to them so they can be inlined. - */ -static inline void -draw_cursor(scr_stat *scp, int show) -{ - if (show && !(scp->status & CURSOR_SHOWN)) { -#ifdef PC98 - int pos = scp->cursor_pos - scp->scr_buf; - while((inb(TEXT_GDC + 0) & 0x04) == 0) {} - outb(TEXT_GDC + 2, 0x49); /* CSRW */ - outb(TEXT_GDC + 0, pos & 0xff); /* EADl */ - outb(TEXT_GDC + 0, pos >> 8); /* EADh */ -#else - u_short cursor_image = *(Crtat + (scp->cursor_pos - scp->scr_buf)); - - scp->cursor_saveunder = cursor_image; - if (configuration & CHAR_CURSOR) { - set_destructive_cursor(scp, FALSE); - cursor_image = (cursor_image & 0xff00) | DEAD_CHAR; - } - else { - if ((cursor_image & 0x7000) == 0x7000) { - cursor_image &= 0x8fff; - if(!(cursor_image & 0x0700)) - cursor_image |= 0x0700; - } else { - cursor_image |= 0x7000; - if ((cursor_image & 0x0700) == 0x0700) - cursor_image &= 0xf0ff; - } - } - *(Crtat + (scp->cursor_pos - scp->scr_buf)) = cursor_image; -#endif - mark_for_update(scp, scp->cursor_pos - scp->scr_buf); -#ifdef PC98 - mark_for_update(scp, scp->cursor_atr - scp->atr_buf); -#endif - scp->status |= CURSOR_SHOWN; - } - if (!show && (scp->status & CURSOR_SHOWN)) { -#ifdef PC98 - /* not supported yet */ -#else - *(Crtat + (scp->cursor_pos - scp->scr_buf)) = scp->cursor_saveunder; -#endif - mark_for_update(scp, scp->cursor_pos - scp->scr_buf); -#ifdef PC98 - mark_for_update(scp, scp->cursor_atr - scp->atr_buf); -#endif - scp->status &= ~CURSOR_SHOWN; - } -} - -static inline void -move_crsr(scr_stat *scp, int x, int y) -{ - if (x < 0) - x = 0; - if (y < 0) - y = 0; - if (x >= scp->xsize) - x = scp->xsize-1; - if (y >= scp->ysize) - y = scp->ysize-1; - scp->xpos = x; - scp->ypos = y; - mark_for_update(scp, scp->cursor_pos - scp->scr_buf); -#ifdef PC98 - mark_for_update(scp, scp->cursor_atr - scp->atr_buf); -#endif - scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; -#ifdef PC98 - scp->cursor_atr = scp->atr_buf + scp->ypos * scp->xsize + scp->xpos; -#endif - mark_for_update(scp, scp->cursor_pos - scp->scr_buf); -#ifdef PC98 - mark_for_update(scp, scp->cursor_atr - scp->atr_buf); -#endif -} - static int scprobe(struct isa_device *dev) { @@ -482,25 +405,100 @@ sc_registerdev(struct isa_device *id) static int scresume(void *dummy) { - shfts = 0; - ctls = 0; - alts = 0; - agrs = 0; - metas = 0; + shfts = ctls = alts = agrs = metas = 0; return 0; } #endif +/* + * These functions need to be before calls to them so they can be inlined. + */ +static inline void +draw_cursor_image(scr_stat *scp) +{ + u_short cursor_image, *ptr; +#ifdef PC98 + int pos = scp->cursor_pos - scp->scr_buf; + while((inb(TEXT_GDC + 0) & 0x04) == 0) {} + outb(TEXT_GDC + 2, 0x49); /* CSRW */ + outb(TEXT_GDC + 0, pos & 0xff); /* EADl */ + outb(TEXT_GDC + 0, pos >> 8); /* EADh */ +#else + ptr = Crtat + (scp->cursor_pos - scp->scr_buf); + + /* do we have a destructive cursor ? */ + if (flags & CHAR_CURSOR) { + cursor_image = *scp->cursor_pos; + scp->cursor_saveunder = cursor_image; + /* modify cursor_image */ + if (!(flags & BLINK_CURSOR)||((flags & BLINK_CURSOR)&&(blinkrate & 4))){ + set_destructive_cursor(scp); + cursor_image &= 0xff00; + cursor_image |= DEAD_CHAR; + } + } + else { + cursor_image = (*(ptr) & 0x00ff) | *(scp->cursor_pos) & 0xff00; + scp->cursor_saveunder = cursor_image; + if (!(flags & BLINK_CURSOR)||((flags & BLINK_CURSOR)&&(blinkrate & 4))){ + if ((cursor_image & 0x7000) == 0x7000) { + cursor_image &= 0x8fff; + if(!(cursor_image & 0x0700)) + cursor_image |= 0x0700; + } else { + cursor_image |= 0x7000; + if ((cursor_image & 0x0700) == 0x0700) + cursor_image &= 0xf0ff; + } + } + } + *ptr = cursor_image; +#endif +} + +static inline void +remove_cursor_image(scr_stat *scp) +{ +/* + u_short cursor_image, *ptr; + + ptr = Crtat + (scp->cursor_oldpos - scp->scr_buf); + + cursor_image = scp->cursor_saveunder; + *ptr = cursor_image; +SOS */ + + *(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder; +} + +static inline void +move_crsr(scr_stat *scp, int x, int y) +{ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (x >= scp->xsize) + x = scp->xsize-1; + if (y >= scp->ysize) + y = scp->ysize-1; + scp->xpos = x; + scp->ypos = y; + scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; + scp->cursor_atr = scp->atr_buf + scp->ypos * scp->xsize + scp->xpos; +} + static int scattach(struct isa_device *dev) { - scr_stat *scp; + scr_stat *scp; + dev_t cdev = makedev(CDEV_MAJOR, 0); #ifdef DEVFS - int vc; + int vc; #endif scinit(); - configuration = dev->id_flags; + flags = dev->id_flags; scp = console[0]; @@ -513,6 +511,7 @@ scattach(struct isa_device *dev) copy_font(SAVE, FONT_16, font_16); fonts_loaded = FONT_16; scp->font_size = FONT_16; + palette = (char *)malloc(3*256, M_DEVBUF, M_NOWAIT); save_palette(); } #endif @@ -528,9 +527,11 @@ scattach(struct isa_device *dev) #ifdef PC98 bcopyw(Atrat, scp->atr_buf, scp->xsize * scp->ysize * sizeof(u_short)); #endif - scp->cursor_pos = scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; + scp->cursor_pos = scp->cursor_oldpos = + scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; #ifdef PC98 - scp->cursor_atr = scp->atr_buf + scp->xpos + scp->ypos * scp->xsize; + scp->cursor_atr = + scp->atr_buf + scp->xpos + scp->ypos * scp->xsize; #endif scp->mouse_pos = scp->scr_buf; @@ -547,9 +548,9 @@ scattach(struct isa_device *dev) #endif /* initialize cursor stuff */ - draw_cursor(scp, TRUE); - if (crtc_vga && (configuration & CHAR_CURSOR)) - set_destructive_cursor(scp, TRUE); + draw_cursor_image(scp); + if (crtc_vga && (flags & CHAR_CURSOR)) + set_destructive_cursor(scp); /* get screen update going */ scrn_timer(); @@ -572,7 +573,7 @@ scattach(struct isa_device *dev) else printf("CGA/EGA"); #endif - printf(" <%d virtual consoles, flags=0x%x>\n", MAXCONS, configuration); + printf(" <%d virtual consoles, flags=0x%x>\n", MAXCONS, flags); #if NAPM > 0 scp->r_hook.ah_fun = scresume; @@ -582,18 +583,13 @@ scattach(struct isa_device *dev) apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook); #endif - { - dev_t dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&cdev, &scdevsw, NULL); - cdevsw_add(&dev, &scdevsw, NULL); - } #ifdef DEVFS for (vc = 0; vc < MAXCONS; vc++) - sc_devfs_token[vc] = devfs_add_devswf(&scdevsw, vc, DV_CHR, - UID_ROOT, GID_WHEEL, 0600, - "ttyv%n", vc); + sc_devfs_token[vc] = devfs_add_devswf(&scdevsw, vc, DV_CHR, UID_ROOT, + GID_WHEEL, 0600, "ttyv%n", vc); #endif - return 0; } @@ -602,7 +598,7 @@ struct tty { int unit = minor(dev); - if (!init_done) + if (init_done == COLD) return(NULL); if (unit > MAXCONS || unit < 0) return(NULL); @@ -831,21 +827,23 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case CONS_CURSORTYPE: /* set cursor type blink/noblink */ if ((*(int*)data) & 0x01) - configuration |= BLINK_CURSOR; + flags |= BLINK_CURSOR; else - configuration &= ~BLINK_CURSOR; + flags &= ~BLINK_CURSOR; if ((*(int*)data) & 0x02) { - configuration |= CHAR_CURSOR; - set_destructive_cursor(scp, TRUE); + if (!crtc_vga) + return ENXIO; + flags |= CHAR_CURSOR; + set_destructive_cursor(scp); } else - configuration &= ~CHAR_CURSOR; + flags &= ~CHAR_CURSOR; return 0; case CONS_BELLTYPE: /* set bell type sound/visual */ if (*data) - configuration |= VISUAL_BELL; + flags |= VISUAL_BELL; else - configuration &= ~VISUAL_BELL; + flags &= ~VISUAL_BELL; return 0; case CONS_HISTORY: /* set history size */ @@ -884,6 +882,9 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case CONS_MOUSECTL: /* control mouse arrow */ { mouse_info_t *mouse = (mouse_info_t*)data; + + if (!crtc_vga) + return ENXIO; switch (mouse->operation) { case MOUSE_MODE: @@ -902,7 +903,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case MOUSE_SHOW: if (!(scp->status & MOUSE_ENABLED)) { scp->status |= MOUSE_ENABLED; - scp->mouse_oldpos = Crtat + (scp->mouse_pos - scp->scr_buf); + scp->mouse_oldpos = scp->mouse_pos; mark_all(scp); } else @@ -1032,9 +1033,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) free(scp->scr_buf, M_DEVBUF); scp->scr_buf = (u_short *)malloc(scp->xsize * scp->ysize * sizeof(u_short),M_DEVBUF, M_WAITOK); +#ifdef PC98 free(scp->atr_buf, M_DEVBUF); scp->atr_buf = (u_short *)malloc(scp->xsize * scp->ysize * sizeof(u_short),M_DEVBUF, M_WAITOK); +#endif if (scp == cur_console) set_mode(scp); clear_screen(scp); @@ -1096,6 +1099,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) free(scp->scr_buf, M_DEVBUF); scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), M_DEVBUF, M_WAITOK); +#ifdef PC98 + free(scp->scr_atr, M_DEVBUF); + scp->scr_atr = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), + M_DEVBUF, M_WAITOK); +#endif free(cut_buffer, M_DEVBUF); cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT); cut_buffer[0] = 0x00; @@ -1240,8 +1248,8 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) copy_font(LOAD, FONT_14, font_14); if (fonts_loaded & FONT_16) copy_font(LOAD, FONT_16, font_16); - if (configuration & CHAR_CURSOR) - set_destructive_cursor(scp, TRUE); + if (flags & CHAR_CURSOR) + set_destructive_cursor(scp); load_palette(); } /* FALL THROUGH */ @@ -1420,6 +1428,8 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case PIO_SCRNMAP: /* set output translation table */ bcopy(data, &scr_map, sizeof(scr_map)); + for (i=0; iterm = kernel_console; current_default = &kernel_default; - if (scp->scr_buf == Crtat) - draw_cursor(scp, FALSE); + if (scp->scr_buf == Crtat) { + remove_cursor_image(scp); + } buf[0] = c; ansi_put(scp, buf, 1); kernel_console = scp->term; current_default = &user_default; scp->term = save; s = splclock(); - if (scp == cur_console) { + if (/* timers_not_running && */ scp == cur_console) { if (scp->scr_buf != Crtat && (scp->start <= scp->end)) { bcopyw(scp->scr_buf + scp->start, Crtat + scp->start, (1 + scp->end - scp->start) * sizeof(u_short)); @@ -1587,9 +1598,9 @@ sccnputc(dev_t dev, int c) #endif scp->start = scp->xsize * scp->ysize; scp->end = 0; - scp->status &= ~CURSOR_SHOWN; } - draw_cursor(scp, TRUE); + scp->cursor_oldpos = scp->cursor_pos; + draw_cursor_image(scp); } splx(s); } @@ -1612,8 +1623,6 @@ sccncheckc(dev_t dev) static void scrn_timer() { - static int cursor_blinkrate; - static int last_mouse_x = -1, last_mouse_y = -1; scr_stat *scp = cur_console; /* should we just return ? */ @@ -1631,23 +1640,61 @@ scrn_timer() bcopyw(scp->atr_buf + scp->start, Atrat + scp->start, (1 + scp->end - scp->start) * sizeof(u_short)); #endif - scp->status &= ~CURSOR_SHOWN; - scp->start = scp->xsize * scp->ysize; - scp->end = 0; - last_mouse_x = last_mouse_y = -1; - } - /* update "pseudo" mouse arrow */ - if ((scp->status & MOUSE_ENABLED) && - (scp->mouse_xpos!=last_mouse_x || scp->mouse_xpos!=last_mouse_x)) { - last_mouse_x = scp->mouse_xpos; - last_mouse_y = scp->mouse_ypos; - draw_mouse_image(scp); } + /* update "pseudo" mouse pointer image */ + if ((scp->status & MOUSE_ENABLED) && crtc_vga) { + /* did mouse move since last time ? */ + if (scp->status & MOUSE_MOVED) { + /* do we need to remove old mouse pointer image ? */ + if (scp->mouse_cut_start != NULL || + (scp->mouse_pos-scp->scr_buf) <= scp->start || + (scp->mouse_pos+scp->xsize+1-scp->scr_buf) >= scp->end) { + remove_mouse_image(scp); + } + scp->status &= ~MOUSE_MOVED; + draw_mouse_image(scp); + } + else { + /* mouse didn't move, has it been overwritten ? */ + if ((scp->mouse_pos+scp->xsize+1-scp->scr_buf) >= scp->start && + (scp->mouse_pos - scp->scr_buf) <= scp->end) { + draw_mouse_image(scp); + } + } + } + /* update cursor image */ - if (scp->status & CURSOR_ENABLED) - draw_cursor(scp, - !(configuration&BLINK_CURSOR) || !(cursor_blinkrate++&0x04)); + if (scp->status & CURSOR_ENABLED) { + /* did cursor move since last time ? */ + if (scp->cursor_pos != scp->cursor_oldpos) { + /* do we need to remove old cursor image ? */ + if ((scp->cursor_oldpos - scp->scr_buf) < scp->start || + ((scp->cursor_oldpos - scp->scr_buf) > scp->end)) { + remove_cursor_image(scp); + } + scp->cursor_oldpos = scp->cursor_pos; + draw_cursor_image(scp); + } + else { + /* cursor didn't move, has it been overwritten ? */ + if (scp->cursor_pos - scp->scr_buf >= scp->start && + scp->cursor_pos - scp->scr_buf <= scp->end) { + draw_cursor_image(scp); + } else { + /* if its a blinking cursor, we may have to update it */ + if (flags & BLINK_CURSOR) + draw_cursor_image(scp); + } + } + blinkrate++; + } + + if (scp->mouse_cut_start != NULL) + draw_cutmarking(scp); + + scp->end = 0; + scp->start = scp->xsize*scp->ysize; } if (scrn_blank_time && (time.tv_sec>scrn_time_stamp+scrn_blank_time)) (*current_saver)(TRUE); @@ -1668,6 +1715,7 @@ clear_screen(scr_stat *scp) scp->xsize * scp->ysize); #endif mark_all(scp); + remove_cutmarking(scp); } static int @@ -1751,8 +1799,8 @@ exchange_scr(void) copy_font(LOAD, FONT_14, font_14); if (fonts_loaded & FONT_16) copy_font(LOAD, FONT_16, font_16); - if (configuration & CHAR_CURSOR) - set_destructive_cursor(new_scp, TRUE); + if (flags & CHAR_CURSOR) + set_destructive_cursor(new_scp); load_palette(); } #endif @@ -2407,20 +2455,20 @@ scan_esc(scr_stat *scp, u_char c) case 'C': /* set cursor type & shape */ if (scp->term.num_param == 1) { if (scp->term.param[0] & 0x01) - configuration |= BLINK_CURSOR; + flags |= BLINK_CURSOR; else - configuration &= ~BLINK_CURSOR; + flags &= ~BLINK_CURSOR; if (scp->term.param[0] & 0x02) { - configuration |= CHAR_CURSOR; - set_destructive_cursor(scp, TRUE); + flags |= CHAR_CURSOR; + set_destructive_cursor(scp); } else - configuration &= ~CHAR_CURSOR; + flags &= ~CHAR_CURSOR; } else if (scp->term.num_param == 2) { scp->cursor_start = scp->term.param[0] & 0x1F; scp->cursor_end = scp->term.param[1] & 0x1F; - if (configuration & CHAR_CURSOR) - set_destructive_cursor(scp, TRUE); + if (flags & CHAR_CURSOR) + set_destructive_cursor(scp); } break; @@ -2825,9 +2873,7 @@ ansi_put(scr_stat *scp, u_char *buf, int len) } /* do we have to scroll ?? */ if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) { - reverse_mouse_cut(scp, 0); - scp->mouse_cut_start = scp->mouse_cut_end = NULL; - scp->status &= ~MOUSE_CUTTING; + remove_cutmarking(scp); if (scp->history) { bcopyw(scp->scr_buf, scp->history_head, scp->xsize * sizeof(u_short)); @@ -2888,9 +2934,9 @@ scinit(void) unsigned hw_cursor; int i; - if (init_done) + if (init_done != COLD) return; - init_done = TRUE; + init_done = WARM; /* * Finish defaulting crtc variables for a mono screen. Crtat is a * bogus common variable so that it can be shared with pcvt, so it @@ -2989,7 +3035,7 @@ scinit(void) console[0] = &main_console; init_scp(console[0]); console[0]->scr_buf = console[0]->mouse_pos = Crtat; - console[0]->cursor_pos = Crtat + hw_cursor; + console[0]->cursor_pos = console[0]->cursor_oldpos = Crtat + hw_cursor; #ifdef PC98 console[0]->atr_buf = Atrat; console[0]->cursor_atr = Atrat + hw_cursor; @@ -3005,9 +3051,10 @@ scinit(void) kernel_console.cur_color = kernel_console.std_color = kernel_default.std_color; kernel_console.rev_color = kernel_default.rev_color; - /* initialize mapscrn array to a one to one map */ - for (i=0; iscr_buf = scp->cursor_pos = scp->mouse_pos = + scp->scr_buf = scp->cursor_pos = scp->cursor_oldpos = scp->mouse_pos = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), M_DEVBUF, M_WAITOK); #ifdef PC98 @@ -3751,12 +3798,11 @@ kbd_cmd(u_char command) } #endif -static void +void set_mode(scr_stat *scp) { char *modetable; char special_modetable[64]; - int font_size; if (scp != cur_console) return; @@ -3848,26 +3894,18 @@ set_mode(scr_stat *scp) modetable = video_mode_ptr + (scp->mode * 64); setup_mode: set_vgaregs(modetable); - font_size = *(modetable + 2); + scp->font_size = *(modetable + 2); /* set font type (size) */ - switch (font_size) { - case 0x10: - outb(TSIDX, 0x03); outb(TSREG, 0x00); /* font 0 */ - scp->font_size = FONT_16; - break; - case 0x0E: - outb(TSIDX, 0x03); outb(TSREG, 0x05); /* font 1 */ - scp->font_size = FONT_14; - break; - default: - case 0x08: + if (scp->font_size < FONT_14) { outb(TSIDX, 0x03); outb(TSREG, 0x0A); /* font 2 */ - scp->font_size = FONT_8; - break; + } else if (scp->font_size >= FONT_16) { + outb(TSIDX, 0x03); outb(TSREG, 0x00); /* font 0 */ + } else { + outb(TSIDX, 0x03); outb(TSREG, 0x05); /* font 1 */ } - if (configuration & CHAR_CURSOR) - set_destructive_cursor(scp, TRUE); + if (flags & CHAR_CURSOR) + set_destructive_cursor(scp); break; case M_BG320: case M_CG320: case M_BG640: @@ -3891,7 +3929,7 @@ set_mode(scr_stat *scp) } void -set_border(int color) +set_border(u_char color) { #ifdef PC98 outb(0x6c, color << 4); @@ -3994,7 +4032,7 @@ set_normal_mode() } #endif -static void +void copy_font(int operation, int font_type, char* font_image) { #ifndef PC98 @@ -4033,36 +4071,28 @@ copy_font(int operation, int font_type, char* font_image) } static void -set_destructive_cursor(scr_stat *scp, int force) +set_destructive_cursor(scr_stat *scp) { #ifndef PC98 u_char cursor[32]; caddr_t address; int i; char *font_buffer; - static u_char old_saveunder = DEAD_CHAR; - u_short new_saveunder; - if (!force && !(scp->status & MOUSE_ENABLED) && - (scp->cursor_saveunder & 0xFF) == old_saveunder) - return; - old_saveunder = force ? DEAD_CHAR : scp->cursor_saveunder & 0xFF; - new_saveunder = scp->cursor_saveunder; - switch (scp->font_size) { - default: - case FONT_8: + + if (scp->font_size < FONT_14) { font_buffer = font_8; address = (caddr_t)VIDEOMEM + 0x8000; - break; - case FONT_14: - font_buffer = font_14; - address = (caddr_t)VIDEOMEM + 0x4000; - break; - case FONT_16: + } + else if (scp->font_size >= FONT_16) { font_buffer = font_16; address = (caddr_t)VIDEOMEM; - break; } + else { + font_buffer = font_14; + address = (caddr_t)VIDEOMEM + 0x4000; + } + if (scp->status & MOUSE_ENABLED) { if ((scp->cursor_saveunder & 0xff) == 0xd0) bcopyw(&scp->mouse_cursor[0], cursor, scp->font_size); @@ -4073,11 +4103,11 @@ set_destructive_cursor(scr_stat *scp, int force) else if ((scp->cursor_saveunder & 0xff) == 0xd3) bcopyw(&scp->mouse_cursor[96], cursor, scp->font_size); else - bcopyw(font_buffer + ((scp->cursor_saveunder&0xff)*scp->font_size), + bcopyw(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size), cursor, scp->font_size); } else - bcopyw(font_buffer + ((scp->cursor_saveunder&0xff) * scp->font_size), + bcopyw(font_buffer + ((scp->cursor_saveunder & 0xff) * scp->font_size), cursor, scp->font_size); for (i=0; i<32; i++) if ((i >= scp->cursor_start && i <= scp->cursor_end) || @@ -4093,6 +4123,7 @@ set_destructive_cursor(scr_stat *scp, int force) static void set_mouse_pos(scr_stat *scp) { + static int last_xpos = -1, last_ypos = -1; /* * the margins imposed here are not ideal, we loose * a couble of pixels on the borders.. @@ -4109,41 +4140,31 @@ set_mouse_pos(scr_stat *scp) if (scp->status & UNKNOWN_MODE) return; - scp->mouse_pos = scp->scr_buf + - ((scp->mouse_ypos/scp->font_size)*scp->xsize + scp->mouse_xpos/8); + if (scp->mouse_xpos != last_xpos || scp->mouse_ypos != last_ypos) { + scp->status |= MOUSE_MOVED; - if ((scp->status & MOUSE_ENABLED) && (scp->status & MOUSE_CUTTING)) { - int s = splclock(); - reverse_mouse_cut(scp, 0); - scp->mouse_cut_end = scp->mouse_pos; - reverse_mouse_cut(scp, 1); - mark_all(scp); - splx(s); - } -} + scp->mouse_pos = scp->scr_buf + + ((scp->mouse_ypos/scp->font_size)*scp->xsize + scp->mouse_xpos/8); -static void -reverse_mouse_cut(scr_stat *scp, int cut) -{ - ushort *ptr; - int i = 0; + if ((scp->status & MOUSE_ENABLED) && (scp->status & MOUSE_CUTTING)) { + u_short *ptr; + int i = 0; - if (scp->mouse_cut_start != NULL && scp->mouse_cut_end != NULL) { - for (ptr = (scp->mouse_cut_start > scp->mouse_cut_end - ? scp->mouse_cut_end : scp->mouse_cut_start); - ptr <= (scp->mouse_cut_start > scp->mouse_cut_end - ? scp->mouse_cut_start : scp->mouse_cut_end); - ptr++) { - *ptr = (*ptr & 0x88ff) | (*ptr & 0x7000)>>4 | (*ptr & 0x0700)<<4; - if (cut) { - cut_buffer[i++] = *ptr & 0xff; - if (((ptr - scp->scr_buf) % scp->xsize) == (scp->xsize - 1)) { + mark_for_update(scp, scp->mouse_cut_start - scp->scr_buf); + mark_for_update(scp, scp->mouse_cut_end - scp->scr_buf); + scp->mouse_cut_end = scp->mouse_pos; + for (ptr = (scp->mouse_cut_start > scp->mouse_cut_end + ? scp->mouse_cut_end : scp->mouse_cut_start); + ptr <= (scp->mouse_cut_start > scp->mouse_cut_end + ? scp->mouse_cut_start : scp->mouse_cut_end); + ptr++) { + cut_buffer[i++] = *ptr & 0xff; + if (((ptr - scp->scr_buf) % scp->xsize) == (scp->xsize - 1)) { cut_buffer[i++] = '\n'; - } + } } - } - if (cut) cut_buffer[i] = 0x00; + } } } @@ -4153,32 +4174,23 @@ mouse_cut_start(scr_stat *scp) int i; if (scp->status & MOUSE_ENABLED) { - reverse_mouse_cut(scp, 0); if (scp->mouse_pos == scp->mouse_cut_start && scp->mouse_cut_start == scp->mouse_cut_end) { - scp->mouse_cut_end = NULL; cut_buffer[0] = 0x00; - scp->status &= ~MOUSE_CUTTING; - mark_all(scp); + remove_cutmarking(scp); } else { scp->mouse_cut_start = scp->mouse_cut_end = scp->mouse_pos; - *scp->mouse_cut_start = (*scp->mouse_cut_start & 0x88ff) | - (*scp->mouse_cut_start & 0x7000) >> 4 | - (*scp->mouse_cut_start & 0x0700) << 4; cut_buffer[0] = *scp->mouse_cut_start & 0xff; cut_buffer[1] = 0x00; scp->status |= MOUSE_CUTTING; - mark_for_update(scp, scp->mouse_cut_start - scp->scr_buf); - set_mouse_pos(scp); } + mark_all(scp); /* delete all other screens cut markings */ for (i=0; istatus &= ~MOUSE_CUTTING; - console[i]->mouse_cut_start = console[i]->mouse_cut_end = NULL; + remove_cutmarking(console[i]); } } } @@ -4200,7 +4212,7 @@ mouse_paste(scr_stat *scp) tp = VIRTUAL_TTY(get_scr_num()); while (*ptr) - (*linesw[tp->t_line].l_rint)(*ptr++, tp); + (*linesw[tp->t_line].l_rint)(scr_rmap[*ptr++], tp); } } @@ -4214,28 +4226,24 @@ draw_mouse_image(scr_stat *scp) u_short buffer[32]; u_short xoffset, yoffset; u_short *crt_pos = Crtat + (scp->mouse_pos - scp->scr_buf); - u_short *ptr = scp->scr_buf + (scp->mouse_oldpos - Crtat); int font_size = scp->font_size; - xoffset = scp->mouse_xpos % 8; - switch (font_size) { - default: - case FONT_8: + if (font_size < FONT_14) { font_buffer = font_8; - yoffset = scp->mouse_ypos % 8; address = (caddr_t)VIDEOMEM + 0x8000; - break; - case FONT_14: - font_buffer = font_14; - yoffset = scp->mouse_ypos % 14; - address = (caddr_t)VIDEOMEM + 0x4000; - break; - case FONT_16: - font_buffer = font_16; - yoffset = scp->mouse_ypos % 16; - address = (caddr_t)VIDEOMEM; - break; } + else if (font_size >= FONT_16) { + font_buffer = font_16; + address = (caddr_t)VIDEOMEM; + } + else { + font_buffer = font_14; + address = (caddr_t)VIDEOMEM + 0x4000; + } + xoffset = scp->mouse_xpos % 8; + yoffset = scp->mouse_ypos % font_size; + + /* prepare mousepointer char's bitmaps */ bcopyw(font_buffer + ((*(scp->mouse_pos) & 0xff) * font_size), &scp->mouse_cursor[0], font_size); bcopyw(font_buffer + ((*(scp->mouse_pos+1) & 0xff) * font_size), @@ -4248,6 +4256,8 @@ draw_mouse_image(scr_stat *scp) buffer[i] = scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32]; buffer[i+font_size]=scp->mouse_cursor[i+64]<<8|scp->mouse_cursor[i+96]; } + + /* now and-or in the mousepointer image */ for (i=0; i<16; i++) { buffer[i+yoffset] = ( buffer[i+yoffset] & ~(mouse_and_mask[i] >> xoffset)) @@ -4259,27 +4269,11 @@ draw_mouse_image(scr_stat *scp) scp->mouse_cursor[i+64] = (buffer[i+font_size] & 0xff00) >> 8; scp->mouse_cursor[i+96] = buffer[i+font_size] & 0xff; } - if (crt_pos != scp->mouse_oldpos) { - *(scp->mouse_oldpos) = scp->mouse_saveunder[0]; - *(scp->mouse_oldpos+1) = scp->mouse_saveunder[1]; - *(scp->mouse_oldpos+scp->xsize) = scp->mouse_saveunder[2]; - *(scp->mouse_oldpos+scp->xsize+1) = scp->mouse_saveunder[3]; - } - scp->mouse_saveunder[0] = *(scp->mouse_pos); - scp->mouse_saveunder[1] = *(scp->mouse_pos+1); - scp->mouse_saveunder[2] = *(scp->mouse_pos+scp->xsize); - scp->mouse_saveunder[3] = *(scp->mouse_pos+scp->xsize+1); - if ((scp->cursor_pos == (ptr)) || - (scp->cursor_pos == (ptr+1)) || - (scp->cursor_pos == (ptr+scp->xsize)) || - (scp->cursor_pos == (ptr+scp->xsize+1)) || - (scp->cursor_pos == (scp->mouse_pos)) || - (scp->cursor_pos == (scp->mouse_pos+1)) || - (scp->cursor_pos == (scp->mouse_pos+scp->xsize)) || - (scp->cursor_pos == (scp->mouse_pos+scp->xsize+1))) - scp->status &= ~CURSOR_SHOWN; - scp->mouse_oldpos = crt_pos; - while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ; + + scp->mouse_oldpos = scp->mouse_pos; + + /* wait for vertical retrace to avoid jitter on some videocards */ + while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ; set_font_mode(); bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128); set_normal_mode(); @@ -4289,9 +4283,65 @@ draw_mouse_image(scr_stat *scp) *(crt_pos+1) = (*(scp->mouse_pos+1)&0xff00)|0xd1; *(crt_pos+scp->xsize+1) = (*(scp->mouse_pos+scp->xsize+1)&0xff00)|0xd3; } + mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf); + mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf); #endif } +static void +remove_mouse_image(scr_stat *scp) +{ + u_short *crt_pos = Crtat + (scp->mouse_oldpos - scp->scr_buf); + + *(crt_pos) = *(scp->mouse_oldpos); + *(crt_pos+1) = *(scp->mouse_oldpos+1); + *(crt_pos+scp->xsize) = *(scp->mouse_oldpos+scp->xsize); + *(crt_pos+scp->xsize+1) = *(scp->mouse_oldpos+scp->xsize+1); + mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf); + mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf); +} + +static void +draw_cutmarking(scr_stat *scp) +{ + u_short *ptr; + u_short och, nch; + + for (ptr=scp->scr_buf; ptr<=(scp->scr_buf+(scp->xsize*scp->ysize)); ptr++) { + nch = och = *(Crtat + (ptr - scp->scr_buf)); + /* are we outside the selected area ? */ + if ( ptr < (scp->mouse_cut_start > scp->mouse_cut_end ? + scp->mouse_cut_end : scp->mouse_cut_start) || + ptr > (scp->mouse_cut_start > scp->mouse_cut_end ? + scp->mouse_cut_start : scp->mouse_cut_end)) { + if (ptr != scp->cursor_pos) + nch = (och & 0xff) | (*ptr & 0xff00); + } + else { + /* are we clear of the cursor image ? */ + if (ptr != scp->cursor_pos) + nch = (och & 0x88ff) | (*ptr & 0x7000)>>4 | (*ptr & 0x0700)<<4; + else { + if (flags & CHAR_CURSOR) + nch = (och & 0x88ff)|(*ptr & 0x7000)>>4|(*ptr & 0x0700)<<4; + else + if (!(flags & BLINK_CURSOR)) + nch = (och & 0xff) | (*ptr & 0xff00); + } + } + if (nch != och) + *(Crtat + (ptr - scp->scr_buf)) = nch; + } +} + +static void +remove_cutmarking(scr_stat *scp) +{ + scp->mouse_cut_start = scp->mouse_cut_end = NULL; + scp->status &= ~MOUSE_CUTTING; + mark_all(scp); +} + #ifndef PC98 static void save_palette(void) @@ -4323,7 +4373,7 @@ load_palette(void) static void do_bell(scr_stat *scp, int pitch, int duration) { - if (configuration & VISUAL_BELL) { + if (flags & VISUAL_BELL) { if (blink_in_progress) return; blink_in_progress = 4; diff --git a/sys/pc98/pc98/syscons.h b/sys/pc98/pc98/syscons.h index 986b7cb7fce7..74b6209631e8 100644 --- a/sys/pc98/pc98/syscons.h +++ b/sys/pc98/pc98/syscons.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.h,v 1.1.1.1 1996/06/14 10:04:47 asami Exp $ + * $Id: syscons.h,v 1.2 1996/07/23 07:46:42 asami Exp $ */ #ifndef _PC98_PC98_SYSCONS_H_ @@ -60,8 +60,8 @@ #define SWITCH_WAIT_ACQ 0x00080 #define BUFFER_SAVED 0x00100 #define CURSOR_ENABLED 0x00200 -#define CURSOR_SHOWN 0x00400 -#define MOUSE_ENABLED 0x00800 +#define MOUSE_ENABLED 0x00400 +#define MOUSE_MOVED 0x00800 #define MOUSE_CUTTING 0x01000 /* configuration flags */ @@ -176,12 +176,12 @@ typedef struct scr_stat { term_stat term; /* terminal emulation stuff */ int status; /* status (bitfield) */ u_short *cursor_pos; /* cursor buffer position */ + u_short *cursor_oldpos; /* cursor old buffer position */ u_short cursor_saveunder; /* saved chars under cursor */ char cursor_start; /* cursor start line # */ char cursor_end; /* cursor end line # */ u_short *mouse_pos; /* mouse buffer position */ u_short *mouse_oldpos; /* mouse old buffer position */ - u_short mouse_saveunder[4]; /* saved chars under mouse */ short mouse_xpos; /* mouse x coordinate */ short mouse_ypos; /* mouse y coordinate */ short mouse_buttons; /* mouse buttons */ @@ -224,7 +224,9 @@ typedef struct default_attr { } default_attr; void load_palette(void); -void set_border(int color); +void set_border(u_char color); +void set_mode(scr_stat *scp); +void copy_font(int operation, int font_type, char* font_image); #ifdef PC98 unsigned int at2pc98(unsigned int attr);