/**************************************************************************** OS/A65 Version 2.0.0 Multitasking Operating System for 6502 Computers Copyright (C) 1989-1998 Andre Fachat This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ****************************************************************************/ /*************************************************************************** * * This file is included in the RESET routine of the kernel, * after the "sei:cld". The routine starting at the bginning * of this file must initialize the hardware to the system RAM * in the beginning and the system ROM in the end of the memory * map. Also the system stack (pointer) is setup. * * In addition to that the system interrupt timer (needed for * task preemtion) must be setup. * * After that the file must define the following macros: * * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz * LEDPORT address of LED port to signal hardware failures * LED_LED bit of LED bit in LEDPORT address * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces * the LED toggle routine if needed. * CLRTIMER() clear the system interrupt timer interrupt * KERNELIRQ() returns if an interrupt occured in the kernel * or outside. Is checked by "BNE IRQ_in_Kernel" * SAVEMEM() save system mem config for interrupt * RESTOREMEM() restore system mem config after interrupt * STARTMEM() This is used to alloc/enable memory pages found * during kernel init. Takes mem size in AC as given * by the kernel init. It is called _after_ inimem! */ /* Kernel routines for ??? hardware */ /* * init stack pointer for system stack */ ldx #<-1 txs /* * init memory configuration */ /* lda #7 sta 0 /* CPU data direction register */ lda #5 sta 1 /* Memory configuration */ */ /* * C64 specific irq timer init, irq every 20ms * We assume that the reset - or a loader program has disabled all irq */ /* lda #<20000 sta C64CIA1+CIA_TBL ; load low byte lda #>20000 sta C64CIA1+CIA_TBH ; load hi byte of counter value lda #%00010001 sta C64CIA1+CIA_CRB ; start counter, counting system pulses lda #%10000010 sta C64CIA1+CIA_ICR ; allow irq */ /* * check zeropage RAM, jump to he_zero if failure */ #include "kernel/zerotest.a65" /* * check system RAM up to ROMSTART, jump to he_ram if failure * returns available RAM in 256 byte blocks in AC */ #include "kernel/ramtest.a65" /* * originally SYSPORT specific, they have a value for the C64 also... */ #define GETFREQ() lda #0 #define LEDPORT $d020 #define LED_LED 1 /* * as we have set the CIA1 TB irq in the kernel, we have to clear the * CIA interrupt flag. This is done with reading the ICRegister. * With C64NEEDCIA1 one can disable reading the ICR here. But then you * have to have a device that does it! */ #if 0 /* ndef C64NEEDCIA1 */ #define CLRTIMER() lda C64CIA1+CIA_ICR #else #define CLRTIMER() #endif /* * MMU systems may map task pages into kernel mem to make copying * easier. This mapping has to be preserved during interrupt. * SAVEMEM() saves the memory configuration, while RESTOREMEM() * restores it, obviously. * These routines are called _after_ "jsr memsys", so this routine * has to preserve this mapping when called from kernel space, * and so must memtask. */ #undef SAVEMEM #undef RESTOREMEM /* * Check if we have an interrupt in the kernel */ #define KERNELIRQ() lda Syscnt:cmp #1 /* * no memory management... */ #define STARTMEM()