URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/rtos/rtems/c/src/lib/libbsp/i960/rxgen960/startup
- from Rev 30 to Rev 173
- ↔ Reverse comparison
Rev 30 → Rev 173
/rom_ibr.h
0,0 → 1,33
/*-------------------------------------*/ |
/* rom_ibr.h */ |
/* Last change : 23. 1.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: rom_ibr.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _ROM_IBR_H_ |
#define _ROM_IBR_H_ |
|
#include "flttbl.h" |
#include "cntrltbl.h" |
#include "intrtbl.h" |
#include "systbl.h" |
|
/* Initial Boot Record. |
*/ |
struct IBR { |
unsigned int busConfig[4]; /* Initial Bus Configuration */ |
void (* start)(void); /* Start Point */ |
struct PRCB * prcb; /* PRCB */ |
unsigned int chckSum[6]; /* CheckSum */ |
}; |
/* Check sum values (defined in *.ld). |
*/ |
extern unsigned int rom_ibr_cksum[]; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/dram.ld
0,0 → 1,154
/*------------------------------------*/ |
/* rom.ld */ |
/* Last change : 19. 4.95 */ |
/*------------------------------------* |
* To build ROM based i960 image. |
*------------------------------------*/ |
/* |
* $Id: dram.ld,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
|
|
MEMORY |
{ |
dram : org = 0xa2000000, len = 120K |
} |
|
|
_bootAddr = 0xa0200000; |
_HEAP = 0xA0100000 ; |
|
SECTIONS |
{ |
/* Only monitor start point and fault handler |
* will live in ROM as far as text is concerned. |
* Only fault table will live in ROM as far as data |
* is concerned. |
*/ |
romCode : |
{ |
/* Make sure that the monitor start point |
* is the first location in EPROM. |
*/ |
rommon.o960(.text) |
/* Procedures to copy code and |
* initialize bss in RAM. |
*/ |
sctns.o960(.text) |
/* Make Sure Fault Table (and its handler's data) |
* live here so that they wouldn't get destroyed). |
*/ |
asmfault.o960 |
flttbl.o960 |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
rom_prcb.o960(.data) |
/* 16 byte aligned Control Table. |
*/ |
. = ALIGN(16); |
rom_cntrltbl.o960(.data) |
. = ALIGN(16); |
intrtbl.o960(.data) |
. = ALIGN(16); |
nulsystbl.o960(.data) |
. = ALIGN(16); |
/* I need this symbol to know where code which is |
* to be copied reside in ROM. Align it on a 16 |
* boundary. |
*/ |
. = ALIGN(16); |
_codeRomStart = .; |
} > dram |
|
/* All the rest of the code will live in RAM. |
* Relocation are created as though code resides |
* in RAM, while code is placed right after romCode. |
* This is responsiblity of the ROM monitor to |
* copy code into ROM. |
*/ |
ramCode : AT(ADDR(romCode) + SIZEOF(romCode)) |
{ |
/* RAM-based code section start. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamStart = .; |
/* RAM based fault recovery stuff. |
*/ |
_faultStart = .; |
fault.o960 |
_faultEnd = .; |
/* Check sum to gurantee that |
* the above section wasn't broken. |
*/ |
. = ALIGN(16); |
_faultCheckSum = .; |
. += 4; |
/* Fault Buffer to keep the state of |
* the fauled procedure. |
*/ |
_faultBuffer = .; |
. += 256; |
/* All the rest of the text goes here. |
*/ |
. = ALIGN(16); |
*(.text) |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
prcb.o960(.data) |
/* 16 byte aligned Control Table. |
*/ |
. = ALIGN(16); |
cntrltbl.o960(.data) |
. = ALIGN(16); |
systbl.o960(.data) |
/* All the rest of program defined data goes here. |
*/ |
*(.data) |
/* RAM-based code section end. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamEnd = .; |
} > sram |
|
/* RAM based uninitialized data. |
*/ |
bss (NOLOAD) : |
{ |
/* BSS section start. I need this symbol to |
* zero BSS on initialization. |
*/ |
_bssStart = .; |
/* Supervisor Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_svrStackPtr = .; |
. += 4K; |
/* Interrupt Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_intStackPtr = .; |
. += 4K; |
/* Program defined BSS. |
*/ |
*(.bss) |
/* Program defined COMMON. |
*/ |
*(COMMON) |
/* BSS section end. I need this symbol to |
* zero BSS on initialization. |
*/ |
_bssEnd = .; |
_bssStart_1 = .; |
_bssEnd_1 = .; |
} > dram |
|
} |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/rxgen_romld.S
0,0 → 1,123
/* |
* $Id: rxgen_romld.S,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "asm.h" |
|
BEGIN_CODE |
|
.globl _romStart |
.globl _start |
.globl _romFaultStart |
.globl _led_array |
.text |
SYM(romStart ): |
SYM(_romStart ): |
# This line is to make compiler happy. |
mov 0, g14 |
ldconst 0x120f,r10 # BIST register |
/* |
Setup code for in memory loaded image |
*/ |
/* |
# Interrupt stack is used by default. |
# Copy all code (except Fault Table and Fault Handler) |
# from EPROM into DRAM. |
*/ |
ldconst 0x120f,r10 //# BIST register |
ldconst 0x2,r3 |
stob r3,0(r10) //# 2->LED |
/* |
# Zero all uninitialized data |
*/ |
callx _zeroBss |
ldconst 0x120f,r10 //# BIST register |
ldconst 0x3,r3 |
stob r3,0(r10) //# 3->LED |
/* |
# And reinitialize processor. |
# _start is a few lines below. |
# _prcb is RAM-based struct PRCB. |
*/ |
ldconst 0x300, r4 |
ldconst _pmc_start, r5 |
ldconst _ram_prcb, r6 |
sysctl r4, r5, r6 |
/* |
# This point will never be reached. |
*/ |
|
SYM(_pmc_start) : |
SYM(pmc_start) : |
ldconst 0x120f,r10 # BIST register |
ldconst 0x4,r3 |
stob r3,0(r10) //# 4->LED |
mov 0, g14 |
/* |
# To get ready to invoke procedures. |
# I'll use supervisor stack. |
*/ |
|
ldconst _svrStackPtr, fp |
lda 16*4(fp), sp |
ldconst 0x5,r3 |
stob r3,0(r10) //# 5->LED |
|
ldconst 0x1F0000, r4 |
ldconst 0x1F2000, r3 |
ldconst 0, r5 |
modpc r4, r3, r5 |
|
ldconst 7,r3 |
stob r3,0(r10) //# 7->LED |
|
callx _rx_boot_card |
/* # if _romMain ever returns ... */ |
b _romExit |
|
SYM(romFaultStart) : |
SYM(_romFaultStart) : |
|
mov 0, g14 |
|
/* ldconst 0, sf0 XXX JRS */ |
/* |
# To get ready to invoke procedures. |
# I'll use supervisor stack. |
# _svrStackPtr is defined directly in rom.ld. |
*/ |
ldconst _svrStackPtr, fp |
lda 16*4(fp), sp |
/* |
# Set processor priority to zero. |
*/ |
ldconst 0x1F0000, r4 |
ldconst 0, r5 |
modpc r4, r4, r5 |
// # Now to real code |
// Fix this up callx _romFaultMain |
callx _rx_boot_card |
// # if _romMain ever returns ... |
b _romExit |
|
_romExit : |
// # if _romMain ever returns ... |
// fmark |
b _romExit |
|
|
|
SYM(led_array): |
.byte 99 |
.byte 1 |
.byte 2 |
.byte 3 |
.byte 4 |
.byte 5 |
.byte 6 |
.byte 7 |
.byte 8 |
.byte 9 |
.byte 0xa |
.byte 0xb |
.byte 0xc |
/bspstart.c
0,0 → 1,157
/* bsp_start() |
* |
* This routine starts the application. It includes application, |
* board, and monitor specific initialization and configuration. |
* The generic CPU dependent initialization has been performed |
* before this routine is invoked. |
* |
* INPUT: NONE |
* |
* OUTPUT: NONE |
* |
* COPYRIGHT (c) 1989-1997. |
* On-Line Applications Research Corporation (OAR). |
* Copyright assigned to U.S. Government, 1994. |
* |
* The license and distribution terms for this file may in |
* the file LICENSE in this distribution or at |
* http://www.OARcorp.com/rtems/license.html. |
* |
* $Id: bspstart.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include <bsp.h> |
#include <rtems/libio.h> |
|
#include <libcsupport.h> |
|
#include <string.h> |
#include <fcntl.h> |
#include <stdio.h> |
#include "i960RP.h" |
#include <rtems/libio.h> |
|
#ifdef STACK_CHECKER_ON |
#include <stackchk.h> |
#endif |
|
#define HEAP_SIZE 1024*1024*2 |
|
/* |
* The original table from the application and our copy of it with |
* some changes. |
*/ |
|
extern int putnum(unsigned int); |
|
extern rtems_configuration_table Configuration; |
extern void bsp_postdriver_hook(void); /* defined in shared directory */ |
|
rtems_configuration_table BSP_Configuration; |
|
rtems_cpu_table Cpu_table; |
|
char *rtems_progname; |
unsigned int top_of_used_memory; |
|
/* |
* Function: bsp_pretasking_hook |
* Created: 95/03/10 |
* |
* Description: |
* BSP pretasking hook. Called just before drivers are initialized. |
* Used to setup libc and install any BSP extensions. |
* |
* NOTES: |
* Must not use libc (to do io) from here, since drivers are |
* not yet initialized. |
* |
*/ |
|
void |
bsp_pretasking_hook(void) |
{ |
|
extern int end; |
rtems_unsigned32 heap_start; |
|
*(unsigned char *)(0x120f) = 0xd; |
/* heap_start = (rtems_unsigned32) &end; */ |
heap_start = (rtems_unsigned32) top_of_used_memory; |
if (heap_start & (CPU_ALIGNMENT-1)) |
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
|
bsp_libc_init((void *) heap_start, 64 * 1024, 0); |
|
|
#ifdef STACK_CHECKER_ON |
/* |
* Initialize the stack bounds checker |
* We can either turn it on here or from the app. |
*/ |
|
*(unsigned char *)(0x120f) = 0xe; |
Stack_check_Initialize(); |
#endif |
|
#ifdef RTEMS_DEBUG |
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
#endif |
*(unsigned char *)(0x120f) = 0xf; |
} |
|
|
/* we need to have the top of memory remembered later to start libc_init with |
the correct values |
*/ |
int rx_boot_card( int argc, char **argv, char **environp) |
{ |
extern int end; |
top_of_used_memory = (rtems_unsigned32) &end + 0x1000; |
if ((argc > 0) && argv && argv[0]) |
rtems_progname = argv[0]; |
else |
rtems_progname = "RTEMS/RP"; |
|
boot_card(argc, argv); |
|
} |
|
bsp_start(void) |
{ |
|
*(unsigned int *)OIMR_ADDR = 0xff; /* Mask all primary PCI Interrupts*/ |
Prcb = get_prcb(); |
Ctl_tbl = Prcb->control_tbl; |
|
*(unsigned char *)(0x120f) = 8; |
/* |
* we do not use the pretasking_hook. |
*/ |
|
Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
Cpu_table.postdriver_hook = bsp_postdriver_hook; |
Cpu_table.do_zero_of_workspace = TRUE; |
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
Cpu_table.extra_mpci_receive_server_stack = 0; |
Cpu_table.Prcb = Prcb; |
|
/* just trying to get along */ |
Cpu_table.stack_allocate_hook = 0; |
Cpu_table.stack_free_hook = 0; |
|
/* |
* Tell libio how many fd's we want and allow it to tweak config |
*/ |
|
*(unsigned char *)(0x120f) = 0x09; |
|
BSP_Configuration.work_space_start = (void *) top_of_used_memory; |
top_of_used_memory += (BSP_Configuration.work_space_size + 0x1000); |
|
|
*(unsigned char *)(0x120f) = 0x0a; |
|
return 0; |
} |
|
/exit.c
0,0 → 1,38
/* exit |
* |
* This routine is used to return control to the NINDY monitor |
* and is automatically invoked by the STDIO exit() routine. |
* |
* INPUT: |
* status - exit status |
* |
* OUTPUT: NONE |
* |
* NOTES: DOES NOT RETURN!!! |
* |
* COPYRIGHT (c) 1989-1997. |
* On-Line Applications Research Corporation (OAR). |
* Copyright assigned to U.S. Government, 1994. |
* |
* The license and distribution terms for this file may in |
* the file LICENSE in this distribution or at |
* http://www.OARcorp.com/rtems/license.html. |
* |
* $Id: exit.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include <rtems.h> |
#include "bsp.h" |
|
void _exit( ) |
{ |
asm volatile( "mov 0,g0; \ |
fmark ; \ |
syncf ; \ |
.word 0xfeedface ; \ |
bx start" : : ); |
/* The constant 0xfeedface is a magic word for break which |
* is defined by NINDY. The branch extended restarts the |
* application if the user types "go". |
*/ |
} |
/types.h
0,0 → 1,38
/* |
* $Id: types.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
/* Type definitions for our use */ |
#ifndef __TYPES_H |
#define __TYPES_H |
typedef unsigned char u8; |
typedef unsigned int u32; |
typedef unsigned short u16; |
typedef unsigned char uchar; |
typedef unsigned int Int32; |
typedef unsigned short Int16; |
typedef unsigned char Int8; |
typedef unsigned int u_int; |
typedef unsigned int u_long; |
typedef unsigned short u_short; |
typedef unsigned char u_char; |
#ifndef NULL |
#define NULL 0 |
#endif |
#ifndef TRUE |
#define TRUE 1 |
#endif |
#ifndef FALSE |
#define FALSE 0 |
#endif |
/* |
* Definitions of unsigned amounts |
*/ |
#define ub Int8 |
#define uw Int16 |
#define ul Int64 |
#define sl long |
#define ui Int32 |
|
|
#endif |
/pmc901_memmap.h
0,0 → 1,12
/* |
* $Id: pmc901_memmap.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
/* Memory map for the pmc901 ; works for most RAMiX PMC/CPCI modules as well */ |
|
#define UART_REG 0xc0000100 |
#define LED_REG 0xc0000200 |
#define DRAM_BASE 0xa0000000 |
#define DRAM_SIZE 0x00400000 |
#define DRAM_SIZE_MASK 0xffc00000 |
#define FLASH_BASE 0xfe000000 |
/fault.c
0,0 → 1,326
/*-------------------------------------*/ |
/* fault.c */ |
/* Last change : 13. 7.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: fault.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "prcb.h" |
#include "i960.h" |
#include "flttbl.h" |
#include "fault.h" |
#include "asmstub.h" |
#include <stdio.h> |
#include <string.h> |
|
extern void romFaultStart(void); |
|
/*-------------------------------------*/ |
/* Table of user-registered fault handler entry. |
*/ |
typedef struct { |
UserFaultHandler hndl; /* Handler itself. */ |
int cnt; /* Handler is valid for cnt times. */ |
} UserFaultEntry; |
/* Table itself. |
*/ |
static UserFaultEntry userFaultTable[] = { |
{0, 0}, /* Parallel */ |
{0, 0}, /* Trace */ |
{0, 0}, /* Operation */ |
{0, 0}, /* Arithmetic */ |
{0, 0}, /* Reserved */ |
{0, 0}, /* Constraint */ |
{0, 0}, /* Reserved */ |
{0, 0}, /* Protection */ |
{0, 0}, /* Reserved */ |
{0, 0} /* Type */ |
}; |
/* Number of Faults. |
*/ |
#define FaultNmbr (sizeof(userFaultTable)/sizeof(UserFaultEntry)) |
|
int faultRegister(int fault, UserFaultHandler hndl, int cnt) |
{ |
static unsigned int faultNewCheckSum(void); |
int rsl = 0; |
|
if (0 <= fault && fault <= FaultNmbr) { |
/* Register handler. |
*/ |
userFaultTable[fault].hndl = hndl; |
userFaultTable[fault].cnt = cnt; |
/* Checksum has changed. |
*/ |
faultCheckSum = faultNewCheckSum(); |
rsl = 1; |
} |
return rsl; |
} |
int faultOk(int fault) |
{ |
static unsigned int faultNewCheckSum(void); |
int rsl = 0; |
|
if (0 <= fault && fault <= FaultNmbr) { |
/* Fault handler recovered successfully. |
* Can use it at least once more. |
*/ |
userFaultTable[fault].cnt ++; |
/* Check sum has changed. |
*/ |
#if 0 |
faultCheckSum = faultNewCheckSum(); |
#endif |
faultCheckSum ++; |
rsl = 1; |
} |
return rsl; |
} |
void faultBad(int invokedFromRom, |
unsigned int inst, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp) |
{ |
static void faultInfo(int invokedFromRom, |
unsigned int inst, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp); |
|
/* Close the mem channel nicely. |
*/ |
/* memChnlI960Fault();*/ |
/* Give some panic message. |
*/ |
faultInfo(invokedFromRom, inst, faultBuffer, type, sbtp); |
/* At this point RAM is repaired. Do |
* whatever you want. |
*/ |
#if 0 |
if (OsfIsUp) { |
asm_exit(romFaultStart, & ram_prcb); |
} |
else { |
asm_exit(romStart, & ram_prcb); |
} |
# endif |
asm_exit(romFaultStart, & ram_prcb); |
} |
void faultGood(unsigned int inst, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp) |
{ |
static unsigned int faultNewCheckSum(void); |
|
if (userFaultTable[type].hndl != 0 && userFaultTable[type].cnt > 0) { |
/* This is done to avoid the situation when |
* handler causes a fault and, thus, infinite recursion. |
*/ |
userFaultTable[type].cnt --; |
/* Check sum has changed. |
*/ |
#if 0 |
faultCheckSum = faultNewCheckSum(); |
#endif |
faultCheckSum --; |
/* Invoke handler. |
*/ |
(* userFaultTable[type].hndl)(inst, faultBuffer, type, sbtp); |
/* If this returns => fault is bad. |
*/ |
} |
faultBad(0, inst, faultBuffer, type, sbtp); |
} |
static unsigned int faultNewCheckSum(void) |
{ |
unsigned int * f = faultStart; |
unsigned int * l = faultEnd; |
unsigned int sum; |
|
for (sum = 0; f < l; f ++) { |
sum += * f; |
} |
return sum; |
} |
static void faultInfo(int invokedFromRom, |
unsigned int inst, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp) |
{ |
char * typeStr; |
char * sbtpStr; |
static char * faultParallelSbtpStr(unsigned int); |
static char * faultTraceSbtpStr(unsigned int); |
static char * faultOperationSbtpStr(unsigned int); |
static char * faultArithmeticSbtpStr(unsigned int); |
static char * faultReservedSbtpStr(unsigned int); |
static char * faultConstraintSbtpStr(unsigned int); |
static char * faultProtectionSbtpStr(unsigned int); |
static char * faultTypeSbtpStr(unsigned int); |
static char * faultUnknownSbtpStr(unsigned int); |
static struct { |
char * name; |
char * (* sbtpStr)(unsigned int); |
} faultInfo[] = { |
{"Parallel", faultParallelSbtpStr}, |
{"Trace", faultTraceSbtpStr}, |
{"Operation", faultOperationSbtpStr}, |
{"Arithmetic", faultArithmeticSbtpStr}, |
{"Reserved", faultReservedSbtpStr}, |
{"Constraint", faultConstraintSbtpStr}, |
{"Reserved", faultReservedSbtpStr}, |
{"Protection", faultProtectionSbtpStr}, |
{"Reserved", faultReservedSbtpStr}, |
{"Type", faultTypeSbtpStr}, |
{"Unknown", faultUnknownSbtpStr} |
}; |
unsigned int ix; |
|
/* console_set_channel(CHANNEL_B);*/ |
ix = type >= FaultNmbr ? FaultNmbr : type; |
typeStr = faultInfo[ix].name; |
sbtpStr = (* faultInfo[ix].sbtpStr)(sbtp); |
printf("\nFault at 0x%08x: %s[%s]\n", |
faultBuffer[IP_REGNUM], typeStr, sbtpStr); |
printf("Bad instruction: 0x%08x\n", inst); |
printf("AC=0x%08x PC=0x%08x\n", |
faultBuffer[ACW_REGNUM], |
faultBuffer[PCW_REGNUM]); |
printf("g0=0x%08x g1=0x%08x g2=0x%08x g3=0x%08x\n", |
faultBuffer[G0_REGNUM+0], faultBuffer[G0_REGNUM+1], |
faultBuffer[G0_REGNUM+2], faultBuffer[G0_REGNUM+3]); |
printf("g4=0x%08x g5=0x%08x g6=0x%08x g7=0x%08x\n", |
faultBuffer[G0_REGNUM+4], faultBuffer[G0_REGNUM+5], |
faultBuffer[G0_REGNUM+6], faultBuffer[G0_REGNUM+7]); |
printf("g8=0x%08x g9=0x%08x gA=0x%08x gB=0x%08x\n", |
faultBuffer[G0_REGNUM+8], faultBuffer[G0_REGNUM+9], |
faultBuffer[G0_REGNUM+10], faultBuffer[G0_REGNUM+11]); |
printf("gC=0x%08x gD=0x%08x gE=0x%08x gF=0x%08x\n", |
faultBuffer[G0_REGNUM+12], faultBuffer[G0_REGNUM+13], |
faultBuffer[G0_REGNUM+14], faultBuffer[G0_REGNUM+15]); |
printf("r0=0x%08x r1=0x%08x r2=0x%08x r3=0x%08x\n", |
faultBuffer[R0_REGNUM+0], faultBuffer[R0_REGNUM+1], |
faultBuffer[R0_REGNUM+2], faultBuffer[R0_REGNUM+3]); |
printf("r4=0x%08x r5=0x%08x r6=0x%08x r7=0x%08x\n", |
faultBuffer[R0_REGNUM+4], faultBuffer[R0_REGNUM+5], |
faultBuffer[R0_REGNUM+6], faultBuffer[R0_REGNUM+7]); |
printf("r8=0x%08x r9=0x%08x rA=0x%08x rB=0x%08x\n", |
faultBuffer[R0_REGNUM+8], faultBuffer[R0_REGNUM+9], |
faultBuffer[R0_REGNUM+10], faultBuffer[R0_REGNUM+11]); |
printf("rC=0x%08x rD=0x%08x rE=0x%08x rF=0x%08x\n", |
faultBuffer[R0_REGNUM+12], faultBuffer[R0_REGNUM+13], |
faultBuffer[R0_REGNUM+14], faultBuffer[R0_REGNUM+15]); |
if (invokedFromRom) { |
printf("RAM image damaged. No chance to recover\n"); |
} |
else { |
printf("RAM image not damaged. Still no recovery\n"); |
} |
} |
static char * faultParallelSbtpStr(unsigned int sbtp) |
{ |
static char buf[10]; |
|
sprintf(buf, "%d", sbtp); |
return buf; |
} |
static char * faultTraceSbtpStr(unsigned int sbtp) |
{ |
static char buf[256]; |
int notEmpty; |
|
buf[0] = '\0'; |
notEmpty = 0; |
if (sbtp & 0x2) { |
strcat(buf, "Instruction"); |
notEmpty = 1; |
} |
if (sbtp & 0x4) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Branch"); |
notEmpty = 1; |
} |
if (sbtp & 0x8) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Call"); |
notEmpty = 1; |
} |
if (sbtp & 0x10) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Return"); |
notEmpty = 1; |
} |
if (sbtp & 0x20) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Prereturn"); |
notEmpty = 1; |
} |
if (sbtp & 0x40) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Supervisor"); |
notEmpty = 1; |
} |
if (sbtp & 0x80) { |
if (notEmpty) strcat(buf, ":"); |
strcat(buf, "Breakpoint"); |
notEmpty = 1; |
} |
if (! notEmpty) { |
strcat(buf, "Unknown"); |
} |
return buf; |
} |
static char * faultOperationSbtpStr(unsigned int sbtp) |
{ |
char * rsl; |
|
if (sbtp == 0x1) rsl = "Invalid Opcode"; |
else if (sbtp == 0x2) rsl = "Unimplemented"; |
else if (sbtp == 0x3) rsl = "Unaligned"; |
else if (sbtp == 0x4) rsl = "Invalid Operand"; |
else rsl = "Unknown"; |
return rsl; |
} |
static char * faultArithmeticSbtpStr(unsigned int sbtp) |
{ |
char * rsl; |
|
if (sbtp == 0x1) rsl = "Integer Overflow"; |
else if (sbtp == 0x2) rsl = "Arithmetic Zero-Divide"; |
else rsl = "Unknown"; |
return rsl; |
} |
static char * faultReservedSbtpStr(unsigned int sbtp) |
{ |
return "Unknown"; |
} |
static char * faultConstraintSbtpStr(unsigned int sbtp) |
{ |
char * rsl; |
|
if (sbtp == 0x1) rsl = "Constraint Range"; |
else if (sbtp == 0x2) rsl = "Priveleged"; |
else rsl = "Unknown"; |
return rsl; |
} |
static char * faultProtectionSbtpStr(unsigned int sbtp) |
{ |
char * rsl; |
|
if (sbtp == 0x1) rsl = "Length"; |
else rsl = "Unknown"; |
return rsl; |
} |
static char * faultTypeSbtpStr(unsigned int sbtp) |
{ |
char * rsl; |
|
if (sbtp == 0x1) rsl = "Type Mismatch"; |
else rsl = "Unknown"; |
return rsl; |
} |
static char * faultUnknownSbtpStr(unsigned int sbtp) |
{ |
return "Unknown"; |
} |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/frmstr.c
0,0 → 1,620
/*-------------------------------------*/ |
/* frmstr.c */ |
/* Last change : 14.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: frmstr.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "frmstr.h" |
/*-------------------------------------*/ |
/* How to treat the rest. |
*/ |
#define FOR_CONSOLE 1 |
#define DO_LONG 1 |
|
/* To Store a byte. |
*/ |
#ifdef _STORE_BYTE |
# define STORE_BYTE(a, b) (store_byte(a, b)) |
long store_byte(void); |
#else |
# define STORE_BYTE(a, b) (* (a) = (b)) |
#endif |
/* Some decalrations. |
*/ |
static void geta(ArgType *, int); |
static const char * gnum(const char *, ArgType * ); |
static char * i_compute(unsigned val, int, char *); |
#ifdef DO_LONG |
static char * l_compute(long, int, char *); |
#endif |
static ArgType * nextarg; |
/* And macros. |
*/ |
#define wsize(par) ((sizeof par) / sizeof(ArgType)) |
#define signbit(par) (1L<<(sizeof par * 8 - 1)) |
|
int format_string(const char * fmt, ArgType * args, char * buffer) |
{ |
char * s; |
# ifdef DO_LONG |
long l; |
int lflag; |
# else |
# define lflag 0 |
# endif |
# ifdef DO_FLOAT |
double dbl; |
# endif |
ArgType inte; |
ArgType_U uint; |
ArgType width, ndigit; |
int i, j, c, rjust, ndfnd, zfill; |
const char * oldfmt; |
char * s1, buf[64]; |
|
nextarg = args; |
while (c = * fmt ++) { |
if (c != '%') { |
# ifdef FOR_CONSOLE |
if (c == '\n') STORE_BYTE(buffer ++, '\r'); |
# endif |
STORE_BYTE(buffer ++, c); |
continue; |
} |
# ifdef DO_LONG |
lflag = 0 ; |
# endif |
j = 10 ; |
rjust = 0; |
if (* fmt == '-') { |
fmt ++; |
rjust ++; |
} |
zfill = ' '; |
if (* fmt == '0') { |
fmt ++; |
zfill = '0'; |
} |
fmt = gnum(fmt, & width); |
ndigit = 0; ndfnd = 0; |
if (* fmt == '.') { |
fmt ++; oldfmt = fmt; |
fmt = gnum(fmt, & ndigit); |
ndfnd = (int)(fmt != oldfmt); |
} |
s = s1 = buf; |
# ifdef DO_LONG |
if (* fmt == 'l' || * fmt == 'L') { |
fmt ++; lflag ++; |
} |
# endif |
switch (c = * fmt ++) { |
default: |
# ifdef FOR_CONSOLE |
if (c == '\n') STORE_BYTE(buffer ++, '\r'); |
# endif |
STORE_BYTE(buffer ++, c); |
continue; |
case 's': |
geta((ArgType *) & s1, wsize(s1)); |
s = s1; |
do { |
if (s == 0) break; |
if (* s == 0) |
break; |
s ++; |
} while (-- ndigit); |
break; |
case 'b': |
j = 2; |
case 'u': |
getu: |
|
if (! lflag) { |
geta(& inte, wsize(inte)); |
goto i_unsignd; |
} |
# ifdef DO_LONG |
case 'U': |
getlu: |
|
geta((ArgType *) & l, wsize(l)); |
goto l_unsignd; |
case 'B': |
j = 2 ; |
goto getlu; |
case 'X': |
j = 16; |
goto getlu; |
case 'O': |
j = 8; |
goto getlu ; |
case 'D': |
l_signed: |
|
geta((ArgType *) & l, wsize(l)); |
if (l < 0) { |
STORE_BYTE(s ++, '-'); |
l = -l; |
} |
goto do_l; |
|
l_unsignd: |
|
if (l && ndigit) |
STORE_BYTE(s ++, '0'); |
|
do_l: |
|
s = l_compute(l, j, s); |
break; |
# endif |
case 'x': |
j = 16; |
goto getu; |
case 'o': |
j = 8; |
goto getu; |
case 'd': |
if (lflag) goto l_signed; |
geta(& inte, wsize(inte)); |
if (inte < 0) { |
STORE_BYTE(s ++, '-'); |
inte = - inte; |
} |
goto do_i; |
|
i_unsignd: |
|
if (inte && ndigit) |
STORE_BYTE(s ++, '0'); |
|
do_i: |
|
s = i_compute(inte, j, s); |
break; |
case 'c': |
geta ((ArgType *) & uint, wsize(uint)); |
for (i = sizeof uint - 1; i >= 0; i --) { |
if (STORE_BYTE(s, uint % 256)) s ++; |
uint /= 256 ; |
} |
break; |
# ifdef DO_FLOAT |
case 'e': |
geta((ArgType *) & dbl, wsize(dbl)); |
s = _pscien(dbl, s, ndigit, ndfnd); |
break; |
case 'f': |
geta((ArgType *) &dbl,wsize(dbl)); |
s = _pfloat(dbl, s, ndigit, ndfnd); |
break; |
# endif |
case 'r': |
geta((ArgType *) & nextarg, wsize(nextarg)); |
geta((ArgType *) & oldfmt, wsize(fmt)); |
fmt = oldfmt; |
continue; |
} |
j = s - s1; |
if ((c = width - j) > 0) { |
if (rjust == 0) { |
do STORE_BYTE(buffer ++, zfill); |
while (-- c); |
} |
} |
while (-- j >= 0) |
STORE_BYTE(buffer ++, * s1 ++); |
while (-- c >= 0) |
STORE_BYTE(buffer ++, zfill); |
} |
STORE_BYTE(buffer, 0); |
return 0; |
} |
static void geta(ArgType * p, int size) |
{ |
if ((ArgType *) & p - (ArgType *) & size > 0) { |
p += size; |
while (size --) { |
* -- p = * nextarg --; |
} |
} |
else { |
while (size --) { |
* p ++ = * nextarg ++ ; |
} |
} |
} |
static const char * gnum(const char * f, ArgType * ip) |
{ |
ArgType i; |
int c; |
|
if (* f == '*') { |
geta(ip, wsize(i)) ; |
f ++; |
} |
else { |
i = 0; |
while ((c = * f - '0') >= 0 && c <= 9) { |
i = i * 10 + c; |
f ++; |
} |
* ip = i; |
} |
return f; |
} |
static char * i_compute(unsigned int val, int base, char * s) |
{ |
int c; |
|
c = val % base; |
val /= base; |
if (val) |
s = i_compute(val, base, s); |
STORE_BYTE(s ++, c>9 ? c-10+'a' : c+'0'); |
return s; |
} |
#ifdef DO_LONG |
static char *l_compute(long l1,int d, char * s) |
{ |
int c; |
long l2; |
|
if (l1 < 0) { |
c = l1 & 1; |
l2 = ((l1>>1) & ~signbit(l1)); |
l1 = l2 / (d>>1); |
c += (l2%(d>>1))<<1; |
} |
else { |
c = l1 % d; |
l1 = l1 / d; |
} |
if (l1) |
s = l_compute(l1, d, s); |
STORE_BYTE(s ++, c>9 ? c-10+'A' : c+'0'); |
return s; |
} |
#endif |
#ifdef _STORE_BYTE |
long store_byte(char * cp, long c) |
{ |
long shift, reg, * ptr; |
|
shift = ((long) cp & 3) * 8; |
ptr = (long *) ((long) cp & ~3); |
reg = * ptr; |
reg &= ~(0xff << shift); |
reg |= c << shift; |
* ptr = reg; |
|
return c; |
} |
#endif |
|
#define SPC 01 |
#define STP 02 |
|
#define NULL 0 |
#define EOF 0 |
#define SHORT 0 |
#define REGULAR 1 |
#define LONG 2 |
#define INT 0 |
#define FLOAT 1 |
|
static int new_c(void); |
static void unnew_c(char); |
static int _innum(int ** ptr, int type, int len, int size, int * eofptr); |
static int _instr(char * ptr, int type, int len, int * eofptr); |
static const char * _getccl(const char *); |
static int vme_isupper(char); |
static int vme_tolower(char); |
static int vme_isdigit(char); |
|
static char _sctab[128] = { |
0,0,0,0,0,0,0,0, |
0,SPC,SPC,0,0,0,0,0, |
0,0,0,0,0,0,0,0, |
0,0,0,0,0,0,0,0, |
SPC,0,0,0,0,0,0,0, |
0,0,0,0,0,0,0,0, |
0,0,0,0,0,0,0,0, |
0,0,0,0,0,0,0,0, |
}; |
static const char * line; |
static char * linep; |
|
int unformat_string(const char * fmt, int ** argp, const char * buffer) |
{ |
int ch; |
int nmatch, len, ch1; |
int ** ptr, fileended, size; |
|
line = buffer; |
linep = (char*)line; |
|
nmatch = 0; |
fileended = 0; |
for (;;) switch (ch = * fmt ++) { |
case '\0': |
return (nmatch); |
case '%': |
if ((ch = * fmt ++) == '%') |
goto def; |
ptr = 0; |
if (ch != '*') |
ptr = argp ++; |
else |
ch = * fmt ++; |
len = 0; |
size = REGULAR; |
while (vme_isdigit(ch)) { |
len = len*10 + ch - '0'; |
ch = * fmt ++; |
} |
if (len == 0) |
len = 30000; |
if (ch == 'l') { |
ch = * fmt ++; |
size = LONG; |
} |
else if (ch == 'h') { |
size = SHORT; |
ch = * fmt ++; |
} |
else if (ch=='[') |
fmt = _getccl(fmt); |
if (vme_isupper(ch)) { |
ch = vme_tolower(ch); |
size = LONG; |
} |
if (ch == '\0') |
return -1; |
if (_innum(ptr, ch, len, size, & fileended) && ptr) |
nmatch ++; |
if (fileended) |
return nmatch? nmatch: -1; |
break; |
case ' ': |
case '\n': |
case '\t': |
while ((ch1 = new_c())==' ' || ch1=='\t' || ch1=='\n') |
; |
if (ch1 != EOF) |
unnew_c(ch1); |
break; |
default: |
|
def: |
|
ch1 = new_c(); |
if (ch1 != ch) { |
if (ch1==EOF) |
return -1 ; |
unnew_c(ch1); |
return nmatch; |
} |
} |
} |
static int new_c() |
{ |
char c; |
|
if (linep) { |
c = * linep ++; |
return c; |
} |
else { |
return 0; |
} |
} |
static void unnew_c(char ch) |
{ |
if (linep > line) |
* (-- linep) = ch; |
} |
static int _innum(int ** ptr, int type, int len, int size, int * eofptr) |
{ |
# ifdef DO_FLOAT |
extern double atof(); |
# endif |
char * np; |
char numbuf[64]; |
int c, base; |
int expseen, scale, negflg, c1, ndigit; |
long lcval; |
|
if (type=='c' || type=='s' || type=='[') |
return _instr(ptr? * (char **) ptr: (char *) NULL, type, len, eofptr); |
lcval = 0; |
ndigit = 0; |
scale = INT; |
if (type=='e'||type=='f') |
scale = FLOAT; |
base = 10; |
if (type=='o') |
base = 8; |
else if (type=='x') |
base = 16; |
np = numbuf; |
expseen = 0; |
negflg = 0; |
while ((c = new_c())==' ' || c=='\t' || c=='\n'); |
if (c=='-') { |
negflg ++; |
* np ++ = c; |
c = new_c(); |
len --; |
} |
else if (c=='+') { |
len --; |
c = new_c(); |
} |
for ( ; -- len >= 0; * np ++ = c, c = new_c()) { |
if (vme_isdigit(c) |
|| base==16 && ('a'<=c && c<='f' || 'A'<=c && c<='F')) { |
ndigit ++; |
if (base==8) |
lcval <<=3; |
else if (base==10) |
lcval = ((lcval<<2) + lcval)<<1; |
else |
lcval <<= 4; |
c1 = c; |
if ('0'<=c && c<='9') |
c -= '0'; |
else if ('a'<=c && c<='f') |
c -= 'a'-10; |
else |
c -= 'A'-10; |
lcval += c; |
c = c1; |
continue; |
} |
else if (c=='.') { |
if (base!=10 || scale==INT) |
break; |
ndigit ++; |
continue; |
} |
else if ((c=='e'||c=='E') && expseen==0) { |
if (base!=10 || scale==INT || ndigit==0) |
break; |
expseen ++; |
* np ++ = c; |
c = new_c(); |
if (c!='+'&&c!='-'&&('0'>c||c>'9')) |
break; |
} |
else |
break; |
} |
if (negflg) |
lcval = -lcval; |
if (c != EOF) { |
unnew_c(c); |
* eofptr = 0; |
} |
else |
* eofptr = 1; |
if (ptr==NULL || np==numbuf) |
return 0; |
* np ++ = 0; |
switch ((scale<<4) | size) { |
# ifdef DO_FLOAT |
|
case (FLOAT<<4) | SHORT: |
case (FLOAT<<4) | REGULAR: |
** (float **) ptr = atof(numbuf); |
break; |
|
case (FLOAT<<4) | LONG: |
** (double **) ptr = atof(numbuf); |
break; |
# endif |
case (INT<<4) | SHORT: |
** (short **) ptr = lcval; |
break; |
|
case (INT<<4) | REGULAR: |
** (int **) ptr = lcval; |
break; |
|
case (INT<<4) | LONG: |
** (long **) ptr = lcval; |
break; |
} |
return 1; |
} |
static int _instr(char * ptr, int type, int len, int * eofptr) |
{ |
int ch; |
char * optr; |
int ignstp; |
|
* eofptr = 0; |
optr = ptr; |
if (type=='c' && len==30000) |
len = 1; |
ignstp = 0; |
if (type=='s') |
ignstp = SPC; |
while (_sctab[ch = new_c()] & ignstp) |
if (ch==EOF) |
break; |
ignstp = SPC; |
if (type=='c') |
ignstp = 0; |
else if (type=='[') |
ignstp = STP; |
while (ch!=EOF && (_sctab[ch]&ignstp)==0) { |
if (ptr) |
* ptr ++ = ch; |
if (-- len <= 0) |
break; |
ch = new_c(); |
} |
if (ch != EOF) { |
if (len > 0) |
unnew_c(ch); |
* eofptr = 0; |
} |
else |
* eofptr = 1; |
if (ptr && ptr!=optr) { |
if (type!='c') |
* ptr ++ = '\0'; |
return 1; |
} |
return 0; |
} |
static const char * _getccl(const char * s) |
{ |
int c, t; |
|
t = 0; |
if (* s == '^') { |
t ++; |
s ++; |
} |
for (c = 0; c < 128; c++) |
if (t) |
_sctab[c] &= ~STP; |
else |
_sctab[c] |= STP; |
while (((c = * s ++)&0177) != ']') { |
if (t) |
_sctab[c++] |= STP; |
else |
_sctab[c++] &= ~STP; |
if (c==0) |
return -- s; |
} |
return s; |
} |
static int vme_isupper(char ch) |
{ |
if( ch >= 'A' & ch <= 'Z') |
return 1; |
else |
return 0; |
} |
static int vme_tolower(char ch) |
{ |
return 'a' + 'A' - ch; |
} |
static vme_isdigit(char ch) |
{ |
if (ch >= '0' & ch <= '9') |
return 1; |
else |
return 0; |
} |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/intrtbl.c
0,0 → 1,57
/*-------------------------------------*/ |
/* intrtbl.c */ |
/* Last change : 12.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: intrtbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "ihandler.h" |
#include "intrtbl.h" |
/*-------------------------------------*/ |
|
|
/* Interrupt Table. Dedicated Interrupts are cached. |
* So NMI handler has to be defined here. |
*/ |
InterruptTbl interruptTbl = { |
0, /* Pending Priorities */ |
0, 0, 0, 0, 0, 0, 0, 0, /* Pending Interrupts */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 8 - 15 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 16 - 23 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 24 - 31 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 32 - 39 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 40 - 47 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 48 - 55 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 56 - 63 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 64 - 71 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 72 - 79 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 87 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 88 - 95 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 96 - 103 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 104 - 111 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 112 - 119 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 120 - 127 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 128 - 135 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 136 - 143 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 144 - 151 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 152 - 159 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 160 - 167 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 168 - 175 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 176 - 183 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 184 - 191 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 192 - 199 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 200 - 207 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 208 - 215 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 216 - 223 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 224 - 231 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 232 - 239 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 240 - 247 */ |
nmiHandler + NORMAL_IH, /* 248 : NMI handler */ |
0, 0, 0, 0, 0, 0, 0, /* 249 - 255 */ |
|
}; |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/fault.h
0,0 → 1,58
/*-------------------------------------*/ |
/* fault.h */ |
/* Last change : 2.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: fault.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _FAULT_H_ |
#define _FAULT_H_ |
|
/* (RAM-based) Fault Handler. |
* Is invoked when there is no chance to repair current state. |
*/ |
extern void faultBad(int invokedFromRom, |
unsigned int inst, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp); |
/* (RAM-based) Fault Handler. |
* Is invoked when there is a chance to repair current state. |
*/ |
extern void faultGood(unsigned int instr, unsigned int * faultBuffer, |
unsigned int type, unsigned int sbtp); |
/* Some addresses that are defined in rom.ld. |
*/ |
extern unsigned int faultCheckSum; |
|
extern unsigned int faultBuffer[]; |
|
extern unsigned int faultStart[]; |
extern unsigned int faultEnd[]; |
/* Interface for user to register fault handlers of his own. |
* Fault names. |
*/ |
#define ParallelFLT 0 |
#define TraceFLT 1 |
#define OperationFLT 2 |
#define ArithmeticFLT 3 |
#define ConstraintFLT 5 |
#define ProtectionFLT 7 |
#define TypeFLT 9 |
/* User-registered fault handler. |
*/ |
typedef void (* UserFaultHandler)(unsigned int inst, unsigned int * faultBuf, |
unsigned int type, unsigned int sbtp); |
/* Register user-defined fault handler. The third argument is |
* how many times this fault handler will be valid. This to avoid |
* the situation when handler is bad and it causes a fault itself. |
*/ |
extern int faultRegister(int fault, UserFaultHandler, int cnt); |
/* Validate handler for one more time. |
*/ |
extern int faultOk(int fault); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/asmfault.h
0,0 → 1,20
/*-------------------------------------*/ |
/* asmfault.h */ |
/* Last change : 3.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: asmfault.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _ASMFAULT_H_ |
#define _ASMFAULT_H_ |
|
/* Fault handler start point. |
*/ |
extern void faultHndlEntry(void); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/frmstr.h
0,0 → 1,44
/* frmstr.h |
* Interface to procedures used to implement |
* the printf group. |
* |
* $Id: frmstr.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _FRMSTR_H_ |
#define _FRMSTR_H_ |
|
#ifdef __i960 |
|
typedef int ArgType; |
typedef unsigned int ArgType_U; |
|
#else |
|
typedef long ArgType; |
typedef unsigned long ArgType_U; |
|
#endif |
|
/* Format a string. |
*/ |
extern int format_string(const char * frmt, ArgType * args, char * buffer); |
/* Get arguments from formatted string. |
*/ |
extern int unformat_string(const char * fmt, int ** argp, const char * buffer); |
|
/* Definitions for control characters. |
*/ |
#define BELL ('G' & 0x1f) |
#define BACKSPACE '\b' |
#define DELETE 0x7f |
#define KILL ('U' - 'A' + 1) |
#define XON ('Q' & 0x1f) |
#define XOFF ('S' & 0x1f) |
#define CNTRL_C 0x3 |
|
#endif |
|
/* End of File |
*/ |
|
/intrtbl.h
0,0 → 1,34
/*-------------------------------------*/ |
/* intrtbl.h */ |
/* Last change : 12.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: intrtbl.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _INTRTBL_H_ |
#define _INTRTBL_H_ |
|
/* Interrupt Handler. |
*/ |
typedef void (* IntrHndl)(void); |
/* Interrupt Table. |
*/ |
typedef struct { |
unsigned int pendPrty; /* Pending Priorities */ |
unsigned int pendIntr[8]; /* Pending Interrupts */ |
IntrHndl intrHndl[248]; /* Interrupt Handlers */ |
} InterruptTbl; |
/* Interrupt Handler Type. |
*/ |
#define NORMAL_IH 0 |
#define IN_CACHE_IH 0x10 |
/* Interrupt Table Itself. |
*/ |
extern InterruptTbl interruptTbl; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/cntrltbl.c
0,0 → 1,89
/*-------------------------------------*/ |
/* cntrltbl.c */ |
/* Last change : 7.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: cntrltbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "i960RP.h" |
#include "cntrltbl.h" |
/*-------------------------------------*/ |
/* Control Table. |
*/ |
/* Interrupt Map Registers Initial. |
*/ |
#define IMAP0 0x4321 |
#define IMAP1 0x8765 |
#define IMAP2 0xA90000 |
#define ICON (VECTOR_CACHE | MSK_UNCHNG | I_ENABLE) |
|
|
/* Bus configuration */ |
#define RP_CONFIG_REGS I960RP_BUS_WIDTH_32 |
#define FLASH I960RP_BUS_WIDTH_8 |
#define DRAM I960RP_BUS_WIDTH_32 |
#define UART_LED I960RP_BUS_WIDTH_8 |
#define DEFAULT I960RP_BUS_WIDTH_32 |
|
/* Region Configuration */ |
#define REGION_0_CONFIG RP_CONFIG_REGS |
#define REGION_2_CONFIG DEFAULT |
#define REGION_4_CONFIG DEFAULT |
#define REGION_6_CONFIG DEFAULT |
#define REGION_8_CONFIG DEFAULT |
#define REGION_A_CONFIG DRAM |
#define REGION_C_CONFIG UART_LED |
|
#define REGION_E_CONFIG DEFAULT |
#define REGION_BOOT_CONFIG DRAM |
|
/* Trace Control Initial. */ |
#define TC 0 |
|
/*Bus Control Initial value */ |
#define BCON CONF_TBL_VALID |
|
|
|
ControlTblEntry controlTbl[] = { |
/* --group 0 -- */ |
0, |
0, |
0, |
0, |
/* --group 1 -- */ |
IMAP0, |
IMAP1, |
IMAP2, |
ICON, |
/* --group 2 -- */ |
REGION_0_CONFIG, |
0, |
REGION_2_CONFIG, |
0, |
/* --group 3 -- */ |
REGION_4_CONFIG, |
0, |
REGION_6_CONFIG, |
0, |
/* --group 4 -- */ |
REGION_8_CONFIG, |
0, |
REGION_A_CONFIG, |
0, |
/* --group 5 -- */ |
REGION_C_CONFIG, |
0, |
REGION_BOOT_CONFIG, |
0, |
/* --group 6 -- */ |
0, /* Reserved */ |
0, |
TC, |
BCON |
}; |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/prcb.c
0,0 → 1,58
/*-------------------------------------*/ |
/* prcb.c */ |
/* Last change : 11.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: prcb.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "flttbl.h" |
#include "cntrltbl.h" |
#include "intrtbl.h" |
#include "systbl.h" |
#include "prcb.h" |
/*-------------------------------------*/ |
/* RAM based PRocess Control Block |
*/ |
#ifdef DBPRECISE_FAULTS |
#define AC (INT_OVFL_DISABLE | PRECISE_FLTS) |
#else |
#define AC (INT_OVFL_DISABLE | IMPRECISE_FLTS) |
#endif |
|
/* Initial Fault Configuration Word Image. |
* As to this 1, I don't know why but without it |
* fault hanlder wouldn't be invoked. |
*/ |
#define FAULT_CONFIG (UNLGND_FAULT_DISABLE | 1) |
|
/* Initial Instruction Cache Configuration Word Image. |
*/ |
#ifdef DBCACHE_OFF |
#define INST_CACHE_CONFIG (INST_CACHE_DISABLE) |
#else |
#define INST_CACHE_CONFIG (INST_CACHE_ENABLE) |
#endif |
|
/* Initial Register Cache Configuration Word Image. |
*/ |
#define REG_CACHE_CONFIG 0x000 |
|
|
struct PRCB ram_prcb = { |
& faultTbl[0], /* Fault Table Base */ |
& controlTbl[0], /* Control Table Base */ |
AC, /* AC */ |
FAULT_CONFIG, /* Fault Configuration Word */ |
& interruptTbl, /* Interrupt Table Base */ |
& systemTbl, /* System Procedure Table Base */ |
0, /* Reserved */ |
& intStackPtr[0], /* Interrupt Stack Pointer */ |
INST_CACHE_CONFIG, /* Instruction Cache Config */ |
REG_CACHE_CONFIG, /* Reg Cache Config */ |
}; |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/flttbl.c
0,0 → 1,121
/*-------------------------------------*/ |
/* flttbl.c */ |
/* Last change : 3.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: flttbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "i960.h" |
#include "string.h" |
#include "sctns.h" |
#include "fault.h" |
#include "asmfault.h" |
#include "flttbl.h" |
/*-------------------------------------*/ |
/* Fault Table. It (as well as all the rest of the |
* code of this file will always stay in ROM, so |
* that it wouldn't be destroyed by silly user code. |
* Thus, at least faults will be always caugth, |
*/ |
FaultTblEntry faultTbl[] = { |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Parallel */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Trace */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Operation */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Arithmetic */ |
{0, 0}, /* Reserved */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Constraint */ |
{0, 0}, /* Reserved */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW}, /* Protection */ |
{0, 0}, /* Reserved */ |
{faultHndlEntry + LOCAL_FH, LOCAL_FW} /* Type */ |
}; |
|
void fltTblInit(void) |
{ |
static unsigned int fltTblCheckSum(void); |
|
faultCheckSum = fltTblCheckSum(); |
} |
static unsigned int fltTblCheckSum(void) |
{ |
unsigned int * f = faultStart; |
unsigned int * l = faultEnd; |
unsigned int sum; |
|
for (sum = 0; f < l; f ++) { |
sum += * f; |
} |
return sum; |
} |
void faultTblHandler(unsigned int * fp, unsigned int * faultBuffer) |
{ |
unsigned int * ip; |
struct typeWord { |
unsigned int sbtp : 8; |
unsigned int : 8; |
unsigned int type : 8; |
unsigned int : 8; |
} tw; |
unsigned int type; |
unsigned int sbtp; |
unsigned int ac; |
unsigned int pc; |
unsigned int inst; |
|
char nib; |
unsigned int i; |
|
/* Address of faulting instruction. |
*/ |
ip = (unsigned int *) fp[-1]; |
/* Type/Subtype word. |
*/ |
|
/* put address of faulting instruction to console */ |
kkprintf("Fault: %x\n", ip); |
|
tw = * (struct typeWord *) & fp[-2]; |
/* Type and subtype. |
*/ |
type = tw.type; |
sbtp = tw.sbtp; |
/* Arithmetic controls. |
*/ |
ac = fp[-3]; |
/* Process controls. |
*/ |
pc = fp[-4]; |
/* Global and local registers are in faultBuffer |
* already. Save the rest. Change RIP to IP. |
*/ |
faultBuffer[IP_REGNUM] = (unsigned int) ip; |
faultBuffer[ACW_REGNUM] = ac; |
faultBuffer[PCW_REGNUM] = pc; |
/* Bad instruction itself. We do |
* this here since it may be repaired (by copying from PROM). |
*/ |
inst = * ip; |
/* Now, to handling. |
*/ |
if (faultCheckSum != fltTblCheckSum()) { |
/* RAM-based fault repair stuff |
* is broken. No chance to recover. |
* Repair RAM memory which is |
* destroyed by silly user. |
*/ |
copyCodeToRom(); |
/* And call RAM-based fault handler. |
*/ |
faultBad(1, inst, faultBuffer, type, sbtp); |
} |
else { |
/* There exist a chance to recover. |
*/ |
faultGood(inst, faultBuffer, type, sbtp); |
} |
} |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/setvec.c
0,0 → 1,202
/* set_vector |
* |
* This routine attempts to perform all "generic" interrupt initialization |
* for the specified XINT line. |
* |
* INPUT: |
* func - interrupt handler entry point |
* xint - external interrupt line |
* type - 0 indicates raw hardware connect |
* 1 indicates RTEMS interrupt connect |
* |
* RETURNS: |
* address of previous interrupt handler |
* |
* COPYRIGHT (c) 1989-1997. |
* On-Line Applications Research Corporation (OAR). |
* Copyright assigned to U.S. Government, 1994. |
* |
* The license and distribution terms for this file may in |
* the file LICENSE in this distribution or at |
* http://www.OARcorp.com/rtems/license.html. |
* |
* $Id: setvec.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
/* |
* i960rp specific function added |
*/ |
|
#include <rtems.h> |
#include <bsp.h> |
|
#include <stdio.h> |
|
void print_prcb(); |
void print_intr_info(); |
void print_ipnd_imsk(); |
|
unsigned int Xint_2_Group_Map[8] = { 0, 1, 2, 5, 7, 3, 6, 4 }; |
|
i960_isr_entry old_set_vector( /* returns old vector */ |
rtems_isr_entry func, /* isr routine */ |
unsigned int xint, /* XINT number */ |
unsigned int type /* RTEMS or RAW */ |
) |
{ |
i960_isr_entry *intr_tbl, *cached_intr_tbl; |
i960_isr_entry saved_intr; |
unsigned int vector, group, nibble; |
unsigned int *imap; |
|
if ( xint > 7 ) |
exit( 0x80 ); |
|
cached_intr_tbl = (i960_isr_entry *) 0; |
intr_tbl = (i960_isr_entry *) Prcb->intr_tbl; |
group = Xint_2_Group_Map[xint]; /* remap XINT to group */ |
vector = (group << 4) + 2; /* direct vector num */ |
|
if ( type ) |
rtems_interrupt_catch( func, vector, (rtems_isr_entry *) &saved_intr ); |
else { |
saved_intr = (i960_isr_entry) intr_tbl[ vector ]; |
/* return old vector */ |
intr_tbl[ vector + 1 ] = /* normal vector table */ |
cached_intr_tbl[ group ] = (i960_isr_entry) func; /* cached vector */ |
} |
|
if ( xint <= 3 ) imap = &Ctl_tbl->imap0; /* updating IMAP0 */ |
else imap = &Ctl_tbl->imap1; /* updating IMAP1 */ |
nibble = (xint % 4) * 4; |
*imap &= ~(0xf << nibble); |
*imap |= group << nibble; |
|
Ctl_tbl->icon &= ~0x00000400; /* enable global interrupts */ |
Ctl_tbl->icon |= 0x00004000; /* fast sampling mode */ |
switch ( xint ) { |
case 0: Ctl_tbl->icon |= 0x00000004; break; |
case 1: Ctl_tbl->icon |= 0x00000008; break; |
case 2: Ctl_tbl->icon &= ~0x00000010; break; |
case 4: Ctl_tbl->icon &= ~0x00000040; break; |
case 5: Ctl_tbl->icon |= 0x00000080; break; |
case 6: Ctl_tbl->icon &= ~0x00000100; break; |
default: exit( 0x81 ); break; /* unsupported */ |
} |
|
#if defined (i960ca) |
if ( xint == 4 ) { /* reprogram MCON for SQSIO4 */ |
Ctl_tbl->mcon12 = 0x00002012; /* MCON12 - 0xCxxxxxxx */ |
Ctl_tbl->mcon13 = 0x00000000; /* MCON13 - 0xDxxxxxxx */ |
i960_reload_ctl_group( 5 ); /* update MCON12-MCON15 */ |
} |
#endif; |
|
i960_unmask_intr( xint ); /* update IMSK */ |
i960_reload_ctl_group( 1 ); /* update IMAP?/ICON */ |
return( saved_intr ); /* return old vector */ |
} |
|
/* note: this needs a little fix up work for XINTs */ |
i960_isr_entry set_vector( /* returns old vector */ |
rtems_isr_entry func, /* isr routine */ |
unsigned int vector, /* vector number */ |
unsigned int type /* RTEMS or RAW */ |
) |
{ |
i960_isr_entry *intr_tbl, *cached_intr_tbl; |
i960_isr_entry saved_intr; |
unsigned int vect_idx, group, nibble; |
unsigned int *imap; |
unsigned int imask; |
unsigned int vec_idx; |
volatile unsigned int *ipnd = (unsigned int *) IPND_ADDR; |
volatile unsigned int *imsk = (unsigned int *) IMSK_ADDR; |
|
|
cached_intr_tbl = (i960_isr_entry *) 0; |
intr_tbl = (i960_isr_entry *) Prcb->intr_tbl; |
|
vec_idx = vector >> 4; |
if ( type ) |
{ |
rtems_interrupt_catch( func, vector, (rtems_isr_entry *) &saved_intr ); |
return (saved_intr); |
} |
else { |
saved_intr = (i960_isr_entry) intr_tbl[ vect_idx ]; |
/* return old vector */ |
intr_tbl[ vector ] = /* normal vector table */ |
cached_intr_tbl[ vec_idx ] = (i960_isr_entry) func; /* cached vector */ |
} |
|
if( vec_idx > 8) |
imask = 0x1000 << (vec_idx - 9); |
else |
imask = 0x1 << (vec_idx - 1); |
*ipnd &= ~(imask); |
*imsk |= (imask); |
|
return( saved_intr ); /* return old vector */ |
} |
|
i960_isr_entry set_tmr_vector( /* returns old vector */ |
rtems_isr_entry func, /* isr routine */ |
unsigned int vector, /* vector number */ |
unsigned int tmrno /* which timer? */ |
) |
{ |
#if defined(i960ca) |
saved_intr = NULL; |
#else |
volatile i960_isr_entry *intr_tbl; |
volatile i960_isr_entry saved_intr; |
volatile unsigned int *imap2 = (unsigned int *) IMAP2_ADDR; |
volatile unsigned int *isr = (unsigned int *) (4*(vector >> 4)); |
|
intr_tbl = (i960_isr_entry *) Prcb->intr_tbl; |
saved_intr = (i960_isr_entry) intr_tbl[ vector ]; |
intr_tbl[vector] = (((int) func) | 0x2); /* set IN_CACHE_IH flag */ |
*isr = (unsigned int) func | 0x2; |
|
if (tmrno) /* timer 1 */ |
{ |
*imap2 = (*imap2 & 0xff0fffff) | (((vector >> 4) & 0xf) << 20); |
} |
else /* timer 0 */ |
{ |
*imap2 = (*imap2 & 0xfff0ffff) | (((vector >> 4) & 0xf) << 16); |
} |
|
#endif |
return( saved_intr ); /* return old vector */ |
} |
|
void print_prcb() |
{ |
printf( "fault_table =0x%p\n", Prcb->fault_tbl ); |
printf( "control_tbl =0x%p\n", Prcb->control_tbl ); |
printf( "AC mask ov =0x%x\n", Prcb->initial_ac ); |
printf( "fltconfig =0x%x\n", Prcb->fault_config ); |
printf( "intr tbl =0x%p\n", Prcb->intr_tbl ); |
printf( "systable =0x%p\n", Prcb->sys_proc_tbl ); |
printf( "reserved =0x%x\n", Prcb->reserved ); |
printf( "isr stk =0x%p\n", Prcb->intr_stack ); |
printf( "ins cache =0x%x\n", Prcb->ins_cache_cfg ); |
printf( "reg cache =0x%x\n", Prcb->reg_cache_cfg ); |
} |
|
void print_intr_info() |
{ |
printf( "prcb =0x%p\n", Prcb ); |
printf( "ctl_tbl =0x%p\n", Ctl_tbl ); |
printf( "intr_tbl=0x%p\n", Prcb->intr_tbl ); |
printf( "IMAP0 = 0x%x\n", Ctl_tbl->imap0 ); |
printf( "IMAP1 = 0x%x\n", Ctl_tbl->imap1 ); |
print_ipnd_imsk(); |
} |
|
void print_ipnd_imsk() |
{ |
printf(" IPEND = 0x%x\n", i960_pend_intrs() ); |
printf(" IMASK = 0x%x\n", i960_mask_intrs() ); |
} |
/cntrltbl.h
0,0 → 1,52
/*-------------------------------------*/ |
/* cntrltbl.h */ |
/* Last change : 11. 1.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: cntrltbl.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _CNTRLTBL_H_ |
#define _CNTRLTBL_H_ |
|
/* Control Table Entry. |
*/ |
typedef unsigned int ControlTblEntry; |
/* Control Table itself. |
*/ |
extern ControlTblEntry controlTbl[]; |
extern ControlTblEntry rom_controlTbl[]; |
|
/* Interrupt Registers Initial. |
*/ |
#define IPB0 0 |
#define IPB1 0 |
#define DAB0 0 |
#define DAB1 0 |
|
#define I_DISABLE (0x1<<10) |
#define I_ENABLE 0 |
|
#define MSK_UNCHNG 0 |
#define MSK_CLEAR (0x1<<11) |
|
#define VECTOR_CACHE (0x1<<13) |
|
|
|
/* BreakPoint Control Register Initial. |
*/ |
#define BPCON 0 |
/* Bus Controller Mode Comstants. |
*/ |
#define CONF_TBL_VALID 0x1 |
#define PROTECT_RAM 0x2 |
#define PROTECT_RAM_SUP 0x4 |
|
|
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/sctns.c
0,0 → 1,103
/*-------------------------------------*/ |
/* sctns.c */ |
/* Last change : 10.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: sctns.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "sctns.h" |
#include "pmc901_memmap.h" |
/*#include "led.h"*/ |
/*-------------------------------------*/ |
|
/* Temporary nullation of WRITE LED */ |
#define WRITE_LED(x) errval = x; |
void ledcyc() |
{ |
register int i,t; |
extern unsigned char * led_array; |
register unsigned char * la; |
volatile register int k,m; |
la = led_array; |
i = 1; |
loop: |
if (i > 9 ) |
i = 1; |
*(unsigned char *) LED_REG = la[i]; |
for(t=1; t < 0x10000; t++) |
k = m + 33; |
i++; |
goto loop; |
} |
|
void copyCodeToRom(void) |
{ |
register int errval = 0; |
unsigned int * s; |
volatile unsigned int * d; |
unsigned int t, i; |
volatile unsigned char * z; |
extern unsigned char * led_array; |
|
WRITE_LED(0x1); |
d = codeRamStart; |
*d = 0; |
if( *d != 0) |
goto error; |
WRITE_LED(0x2); |
*d = 0xffffffff; |
if( *d != 0xffffffff) |
goto error; |
WRITE_LED(0x3); |
t = 1; |
for( i=0; i < 31; i++){ |
*d = t; |
if(*d != t) |
goto error; |
t <<= 1; |
} |
z = (unsigned char *)codeRamStart; |
*z = 0; |
if( *z != 0) |
goto error; |
*z = 0xf; |
if( *z != 0xf) |
goto error; |
WRITE_LED(0x4); |
for (s = codeRomStart, d = codeRamStart; d < codeRamEnd; s ++, d ++) { |
* d = * s; |
} |
WRITE_LED(0x5); |
for (s = codeRomStart, d = codeRamStart; d < codeRamEnd; s ++, d ++) { |
if( * d != * s ) |
goto error; |
} |
WRITE_LED(0x6); |
return; |
|
error: |
while(1){ |
for(t=1; t < 0x100000; t++) |
*(unsigned char *) LED_REG = errval; |
for(t=1; t < 0x100000; t++) |
*(unsigned char *) LED_REG = led_array[0]; |
} |
|
} |
void zeroBss(void) |
{ |
unsigned int * p; |
|
extern unsigned int bssStart_1[], bssEnd_1[]; |
|
for (p = bssStart; p < bssEnd; p ++) { |
* p = 0; |
} |
for (p = bssStart_1; p < bssEnd_1; p ++) { |
* p = 0; |
} |
} |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/prcb.h
0,0 → 1,61
/*-------------------------------------*/ |
/* prcb.h */ |
/* Last change : 11. 1.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: prcb.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _PRCB_H_ |
#define _PRCB_H_ |
|
#include "flttbl.h" |
#include "cntrltbl.h" |
#include "intrtbl.h" |
#include "systbl.h" |
|
/* PRocess Control Block |
*/ |
struct PRCB { |
FaultTblEntry * faultTbl; /* Fault Table Base */ |
ControlTblEntry * controlTbl; /* Control Table Base */ |
unsigned int arithConfig; /* Arithmetic Control Register Image */ |
unsigned int faultConfig; /* Fault Configuration Word Image */ |
InterruptTbl * interruptTbl; /* Interrupt Table Base */ |
SystemTbl * systemTbl; /* System Procedure Table Base */ |
unsigned int reserved; /* Reserved */ |
unsigned int * intStackPtr; /* Interrupt Stack Pointer */ |
unsigned int instCacheConfig; /* Instruction Cache Config */ |
unsigned int regCacheConfig; /* Register Cache Config */ |
}; |
/* Constants for Arithmetic Control Register. |
*/ |
#define INT_OVFL_ENABLE 0 |
#define INT_OVFL_DISABLE 0x1000 |
|
#define PRECISE_FLTS 0x8000 |
#define IMPRECISE_FLTS 0 |
/* Constants for Fault Configuration Word. |
*/ |
#define UNLGND_FAULT_ENABLE 0 |
#define UNLGND_FAULT_DISABLE 0x40000000 |
/* Constants for Instruction Cache Configuration Word. |
*/ |
#define INST_CACHE_ENABLE 0 |
#define INST_CACHE_DISABLE 0x10000 |
/* RAM-based Process Control Block. |
*/ |
extern struct PRCB ram_prcb; |
extern struct PRCB rom_prcb; |
/* Supervisor Stack. Is defined directly in rom.ld. |
*/ |
extern unsigned int svrStackPtr[]; |
/* Interrupt Stack. Is defined directly in rom.ld. |
*/ |
extern unsigned int intStackPtr[]; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/flttbl.h
0,0 → 1,40
/*-------------------------------------*/ |
/* fltbl.h */ |
/* Last change : 3.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: flttbl.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _FLTTBL_H_ |
#define _FLTTBL_H_ |
|
/* FaultTable Entry. |
*/ |
typedef struct { |
void (* hndl)(void); /* Fault Handle */ |
unsigned int type; /* Fault Table Type */ |
} FaultTblEntry; |
/* Fault Handler Type. |
*/ |
#define LOCAL_FH 0 |
#define SYSTEM_FH 0x10 |
|
#define LOCAL_FW 0 |
#define SYSTEM_FW 0x027F |
/* FaultTable Itself. |
*/ |
extern FaultTblEntry faultTbl[]; |
/* To initialize fault handling. |
*/ |
extern void faultTblInit(void); |
/* Fault handler. Invoked from low-level handler. |
*/ |
extern void faultTblHandler(unsigned int * fp, |
unsigned int * faultBuffer); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/asmstub.S
0,0 → 1,145
# |
# $Id: asmstub.S,v 1.2 2001-09-27 11:59:59 chris Exp $ |
# |
|
####################################### |
# asmstub.s # |
# Last change : 20. 1.95 # |
####################################### |
|
######################################################################## |
# |
# PURPOSE: resets processor |
# |
# ARGUMENTS: g0 = start point |
# g1 = prcb |
# |
# RETURNS: none |
######################################################################## |
|
.text |
.globl _asm_exit |
|
.text |
_asm_exit: |
ldconst 0x300, g2 |
# ldconst _start, g1 |
# ldconst _ram_prcb, g2 |
sysctl g2, g0, g1 |
ret |
|
######################################################################## |
# |
# PURPOSE: execute sysctl instruction |
# |
# ARGUMENTS: g0 = message type (0x300 for reinitialize) |
# g1 = depends on type (inst addr for reinitialize) |
# g2 = depends on type (prcb addr for reinitialize) |
# |
# RETURNS: none |
######################################################################## |
|
.text |
.globl _asm_sysctl |
|
.text |
_asm_sysctl: |
b _asm_sysctl |
sysctl g0, g1, g2 |
ret |
|
######################################################################## |
# |
# PURPOSE: alter a bit in the interrupt pending register |
# |
# ARGUMENTS: g0 = interrupt number |
# g1 = 1 to set, 0 to clear |
# |
# RETURNS: none |
######################################################################## |
|
.text |
.globl _asm_ipend |
|
.text |
_asm_ipend: |
chkbit 0, g1 |
/* alterbit g0, sf0, sf0 XXX JRS */ |
ret |
######################################################################## |
# |
# PURPOSE: alter a bit in the interrupt mask register |
# |
# ARGUMENTS: g0 = interrupt number |
# g1 = 1 to set, 0 to clear |
# |
# RETURNS: none |
######################################################################## |
|
.text |
.globl _asm_imask |
|
.text |
_asm_imask: |
chkbit 0, g1 |
/* alterbit g0, sf1, sf1 XXX JRS */ |
ret |
|
|
######################################################################## |
# |
# PURPOSE: get the value of the interrupt mask register |
# |
# ARGUMENTS: none |
# |
# RETURNS: value of IMASK reg |
######################################################################## |
|
.text |
.globl _asm_get_imask |
|
.text |
_asm_get_imask: |
/* mov sf1, g0 XXX JRS */ |
ret |
|
######################################################################## |
# |
# PURPOSE: modify process-controls register |
# |
# ARGUMENTS: g0 = value masked/stored in PC reg |
# g1 = mask of bits to be modified |
# |
# RETURNS: g0 = initial value of PC reg |
######################################################################## |
|
.text |
.globl _asm_modpc |
|
.text |
_asm_modpc: |
modpc g1, g1, g0 |
ret |
|
######################################################################## |
# |
# PURPOSE: change a cached interrupt vector |
# |
# ARGUMENTS: g0 = interrupt number |
# g1 = new interrupt vector |
# |
# RETURNS: none |
######################################################################## |
|
.text |
.globl _asm_ivector |
|
.text |
_asm_ivector: |
addo 1, g0, g0 |
st g1, [g0 * 4] |
ret |
|
############### |
# End of file # |
############### |
/sctns.h
0,0 → 1,37
/*-------------------------------------*/ |
/* sctns.h */ |
/* Last change : 10.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: sctns.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _SCTNS_H_ |
#define _SCTNS_H_ |
|
/* Copy all code into SRAM. |
* Fault Table and Fault Handler stays in EPROM to not be |
* destroyed by a buggy user program. Beyond that only |
* monitor Start point and procedures to copy code |
* into RAM will be relocated in ROM. |
*/ |
extern void copyCodeToRam(void); |
/* Zero uninitialized section. |
*/ |
extern void zeroBss(void); |
|
/* Some relocation symbols. These |
* symbols are defined in rom.ld. |
*/ |
extern unsigned int codeRomStart[]; |
extern unsigned int codeRamStart[]; |
extern unsigned int codeRamEnd[]; |
|
extern unsigned int bssStart[]; |
extern unsigned int bssEnd[]; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/nulsystbl.c
0,0 → 1,83
/*-------------------------------------*/ |
/* systbl.c */ |
/* Last change : 21. 3.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: nulsystbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "prcb.h" |
#include "systbl.h" |
/*-------------------------------------*/ |
/* System Procedures Table. |
* Dummy version that will live in ROM at all times |
* RP does fetch on it, so must be present here rather than pointing |
* to ram |
*/ |
SystemTbl nulsystemTbl = { |
0, 0, 0, /* Reserved */ |
svrStackPtr, /* Supervisor Stack Pointer Base */ |
0, 0, 0, 0, 0, 0, 0, 0, /* Preserved */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 8 - 15 */ |
0, 0, /* 16 - 17 */ |
0, /* 18 */ |
0, /* 19 */ |
0, /* 20 */ |
0, /* 21 */ |
0, 0, /* 22 - 23 */ |
0, /* 24 */ |
0, /* 25 */ |
0, /* 26 */ |
0, /* 27 */ |
0, /* 28 */ |
0, /* 29 */ |
0, /* 30 */ |
0, /* 31 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 32 - 39 */ |
0, /* 40 */ |
0, /* 41 */ |
0, /* 42 */ |
0, /* 43 */ |
0, /* 44 */ |
0, /* 45 */ |
0, /* 46 */ |
0, /* 47 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 48 - 55 */ |
0, /* 56 */ |
0, /* 57 */ |
0, /* 58 */ |
0, 0, 0, 0, 0, /* 59 - 63 */ |
0, /* 64 */ |
0, /* 65 */ |
0, 0, 0, 0, 0, 0, /* 66 - 71 */ |
0, /* 72 */ |
0, /* 73 */ |
0, /* 74 */ |
0, /* 75 */ |
0, /* 76 */ |
0, /* 77 */ |
0, 0, /* 78 - 79 */ |
0, /* 80 */ |
0, /* 81 */ |
0, 0, 0, 0, 0, 0, /* 82 - 87 */ |
0, /* 88 */ |
0, 0, 0, 0, 0, 0, 0, /* 89 - 95 */ |
0, /* 96 */ |
0, /* 97 */ |
0, 0, 0, 0, 0, 0, /* 98 - 103 */ |
0, /* 104 */ |
0, /* 105 */ |
0, /* 106 */ |
0, /* 107 */ |
0, /* 108 */ |
0, /* 109 */ |
0, 0, /* 110 - 111 */ |
0, /* 112 */ |
0, /* 113 */ |
0, /* 114 */ |
}; |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/rom_cntrltbl.c
0,0 → 1,89
/*-------------------------------------*/ |
/* cntrltbl.c */ |
/* Last change : 7.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: rom_cntrltbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include <i960RP.h> |
#include "cntrltbl.h" |
/*-------------------------------------*/ |
/* Control Table. |
*/ |
/* Interrupt Map Registers Initial. |
*/ |
#define IMAP0 0x4321 |
#define IMAP1 0x8765 |
#define IMAP2 0xA90000 |
#define ICON (VECTOR_CACHE | MSK_UNCHNG | I_ENABLE) |
|
|
/* Bus configuration */ |
#define RP_CONFIG_REGS I960RP_BUS_WIDTH_32 |
#define FLASH I960RP_BUS_WIDTH_8 |
#define DRAM I960RP_BUS_WIDTH_32 |
#define UART_LED I960RP_BUS_WIDTH_8 |
#define DEFAULT I960RP_BUS_WIDTH_32 |
|
/* Region Configuration */ |
#define REGION_0_CONFIG RP_CONFIG_REGS |
#define REGION_2_CONFIG DEFAULT |
#define REGION_4_CONFIG DEFAULT |
#define REGION_6_CONFIG DEFAULT |
#define REGION_8_CONFIG DEFAULT |
#define REGION_A_CONFIG DRAM |
#define REGION_C_CONFIG UART_LED |
|
#define REGION_E_CONFIG DEFAULT |
#define REGION_BOOT_CONFIG (DRAM ) |
|
/* Trace Control Initial. */ |
#define TC 0 |
|
/*Bus Control Initial value */ |
#define BCON CONF_TBL_VALID |
|
|
|
ControlTblEntry rom_controlTbl[] = { |
/* --group 0 -- */ |
0, |
0, |
0, |
0, |
/* --group 1 -- */ |
IMAP0, |
IMAP1, |
IMAP2, |
ICON, |
/* --group 2 -- */ |
REGION_0_CONFIG, |
0, |
REGION_2_CONFIG, |
0, |
/* --group 3 -- */ |
REGION_4_CONFIG, |
0, |
REGION_6_CONFIG, |
0, |
/* --group 4 -- */ |
REGION_8_CONFIG, |
0, |
REGION_A_CONFIG, |
0, |
/* --group 5 -- */ |
REGION_C_CONFIG, |
0, |
REGION_BOOT_CONFIG, |
0, |
/* --group 6 -- */ |
0, /* Reserved */ |
0, |
TC, |
BCON |
}; |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/time.h
0,0 → 1,6
/* |
* $Id: time.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
extern void gettime_impl(void); |
extern void gettime_us_impl(void); |
/rom_prcb.c
0,0 → 1,59
/*-------------------------------------*/ |
/* prcb.c */ |
/* Last change : 11.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: rom_prcb.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "flttbl.h" |
#include "cntrltbl.h" |
#include "intrtbl.h" |
#include "systbl.h" |
#include "prcb.h" |
/*-------------------------------------*/ |
/* RAM based PRocess Control Block |
*/ |
#ifdef DBPRECISE_FAULTS |
#define AC (INT_OVFL_DISABLE | PRECISE_FLTS) |
#else |
#define AC (INT_OVFL_DISABLE | IMPRECISE_FLTS) |
#endif |
|
/* Initial Fault Configuration Word Image. |
* As to this 1, I don't know why but without it |
* fault hanlder wouldn't be invoked. |
*/ |
#define FAULT_CONFIG (UNLGND_FAULT_DISABLE | 1) |
extern SystemTbl nulsystemTbl; |
|
/* Initial Instruction Cache Configuration Word Image. |
*/ |
#ifdef DBCACHE_OFF |
#define INST_CACHE_CONFIG (INST_CACHE_DISABLE) |
#else |
#define INST_CACHE_CONFIG (INST_CACHE_ENABLE) |
#endif |
|
/* Initial Register Cache Configuration Word Image. |
*/ |
#define REG_CACHE_CONFIG 0x200 |
|
|
struct PRCB rom_prcb = { |
& faultTbl[0], /* Fault Table Base */ |
& rom_controlTbl[0], /* Control Table Base */ |
AC, /* AC */ |
FAULT_CONFIG, /* Fault Configuration Word */ |
& interruptTbl, /* Interrupt Table Base */ |
& nulsystemTbl, /* System Procedure Table Base */ |
0, /* Reserved */ |
& intStackPtr[0], /* Interrupt Stack Pointer */ |
INST_CACHE_CONFIG, /* Instruction Cache Config */ |
REG_CACHE_CONFIG, /* Reg Cache Config */ |
}; |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/ihandler.S
0,0 → 1,54
# |
# $Id: ihandler.S,v 1.2 2001-09-27 11:59:59 chris Exp $ |
# |
|
####################################### |
# ihandler.s # |
# Last change : 8.11.94 # |
####################################### |
|
.text |
.globl _nmiHandler |
.globl _intr5Handler |
.globl _intr6Handler |
.globl _clockHandler |
|
.text |
|
# NMI Handler |
_nmiHandler : |
ldconst 64, r4 |
addo sp, r4, sp |
|
stq g0, -64(sp) |
stq g4, -48(sp) |
stq g8, -32(sp) |
stt g12, -16(sp) |
|
callx _nmi_isr |
|
ldq -64(sp), g0 |
ldq -48(sp), g4 |
ldq -32(sp), g8 |
ldt -16(sp), g12 |
|
ret |
_clockHandler : |
ldconst 64, r4 |
addo sp, r4, sp |
|
stq g0, -64(sp) |
stq g4, -48(sp) |
stq g8, -32(sp) |
stt g12, -16(sp) |
|
callx _Clock_isr |
|
ldq -64(sp), g0 |
ldq -48(sp), g4 |
ldq -32(sp), g8 |
ldt -16(sp), g12 |
# |
# |
ret |
|
/rom.ld
0,0 → 1,162
/*------------------------------------*/ |
/* rom.ld */ |
/* Last change : 19. 4.95 */ |
/*------------------------------------* |
* To build ROM based i960 image. |
*------------------------------------*/ |
|
/* |
* $Id: rom.ld,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
|
MEMORY |
{ |
config : org = 0xFeffFF30, len = 0xd0 |
eprom : org = 0xfef80000, len = 120K |
sram : org = 0xA0000000, len = 128K |
} |
|
_rom_ibr_cksum = -(_romStart + _rom_prcb); |
|
_bootAddr = 0xa0200000; |
_HEAP = 0xA0100000 ; |
|
SECTIONS |
{ |
prcb : |
{ |
rom_ibr.o960 |
} > config |
|
/* Only monitor start point and fault handler |
* will live in ROM as far as text is concerned. |
* Only fault table will live in ROM as far as data |
* is concerned. |
*/ |
romCode : |
{ |
/* Make sure that the monitor start point |
* is the first location in EPROM. |
*/ |
rommon.o960(.text) |
/* Procedures to copy code and |
* initialize bss in RAM. |
*/ |
sctns.o960(.text) |
/* Make Sure Fault Table (and its handler's data) |
* live here so that they wouldn't get destroyed). |
*/ |
asmfault.o960 |
flttbl.o960 |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
rom_prcb.o960(.data) |
/* 16 byte aligned Control Table. |
*/ |
. = ALIGN(16); |
rom_cntrltbl.o960(.data) |
. = ALIGN(16); |
intrtbl.o960(.data) |
. = ALIGN(16); |
nulsystbl.o960(.data) |
. = ALIGN(16); |
/* I need this symbol to know where code which is |
* to be copied reside in ROM. Align it on a 16 |
* boundary. |
*/ |
. = ALIGN(16); |
_codeRomStart = .; |
} > eprom |
|
/* All the rest of the code will live in RAM. |
* Relocation are created as though code resides |
* in RAM, while code is placed right after romCode. |
* This is responsiblity of the ROM monitor to |
* copy code into ROM. |
*/ |
ramCode : AT(ADDR(romCode) + SIZEOF(romCode)) |
{ |
/* RAM-based code section start. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamStart = .; |
/* RAM based fault recovery stuff. |
*/ |
_faultStart = .; |
fault.o960 |
_faultEnd = .; |
/* Check sum to gurantee that |
* the above section wasn't broken. |
*/ |
. = ALIGN(16); |
_faultCheckSum = .; |
. += 4; |
/* Fault Buffer to keep the state of |
* the fauled procedure. |
*/ |
_faultBuffer = .; |
. += 256; |
/* All the rest of the text goes here. |
*/ |
. = ALIGN(16); |
*(.text) |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
prcb.o960(.data) |
/* 16 byte aligned Control Table. |
*/ |
. = ALIGN(16); |
cntrltbl.o960(.data) |
. = ALIGN(16); |
systbl.o960(.data) |
/* All the rest of program defined data goes here. |
*/ |
*(.data) |
/* RAM-based code section end. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamEnd = .; |
} > sram |
|
/* RAM based uninitialized data. |
*/ |
bss (NOLOAD) : |
{ |
/* BSS section start. I need this symbol to |
* zero BSS on initialization. |
*/ |
_bssStart = .; |
/* Supervisor Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_svrStackPtr = .; |
. += 4K; |
/* Interrupt Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_intStackPtr = .; |
. += 4K; |
/* Program defined BSS. |
*/ |
*(.bss) |
/* Program defined COMMON. |
*/ |
*(COMMON) |
/* BSS section end. I need this symbol to |
* zero BSS on initialization. |
*/ |
_bssEnd = .; |
_bssStart_1 = .; |
_bssEnd_1 = .; |
} > sram |
|
} |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/rommon.h
0,0 → 1,30
/*-------------------------------------*/ |
/* rommon.h */ |
/* Last change : 23. 1.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: rommon.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _ROMMON_H_ |
#define _ROMMON_H_ |
|
/* ROM monitor start point. |
* Gets control on power on. |
*/ |
extern void romStart(void); |
extern void start(void); |
/* ROM monitor start point. |
* Gets control on a fault. |
*/ |
extern void romFaultStart(void); |
/* ROM monitor start point. |
* Gets control on a test command. |
*/ |
extern void romTestStart(void); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/systbl.c
0,0 → 1,101
/*-------------------------------------*/ |
/* systbl.c */ |
/* Last change : 21. 3.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: systbl.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "prcb.h" |
/*#include "uart_access.h" */ |
#include "fault.h" |
#include "faultret.h" |
#include "memchnl.h" |
#include "main.h" |
/*#include "string_impl.h"*/ |
#include "stdio.h" |
/* #include "stdio_impl.h" */ |
#include "systbl.h" |
#include "time.h" |
/*-------------------------------------*/ |
|
struct PRCB *sys_get_prcb() |
{ |
register struct PRCB *prcb = &ram_prcb; |
|
return(prcb); |
/*asm volatile("lda _ram_prcb, g0" : : ); */ |
} |
|
/* System Procedures Table. |
*/ |
SystemTbl systemTbl = { |
{0, 0, 0}, /* Reserved */ |
svrStackPtr, /* Supervisor Stack Pointer Base */ |
{0, 0, 0, 0, 0, 0, 0, 0}, /* Preserved */ |
{0, 0, 0, 0, 0, |
SP(sys_get_prcb + SUPERVISOR_SP), |
0, 0, /* 6 - 7 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 8 - 15 */ |
0, 0, /* 16 - 17 */ |
0, /* 18 */ |
0, /* 19 */ |
0, /* 20 */ |
0, /* 21 */ |
0, 0, /* 22 - 23 */ |
0, /* 24 */ |
0, /* 25 */ |
0, /* 26 */ |
0, /* 27 */ |
0, /* 28 */ |
0, /* 29 */ |
0, /* 30 */ |
0, /* 31 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 32 - 39 */ |
0, /* 40 */ |
0, /* 41 */ |
0, /* 42 */ |
0, /* 43 */ |
0, /* 44 */ |
0, /* 45 */ |
0, /* 46 */ |
0, /* 47 */ |
0, 0, 0, 0, 0, 0, 0, 0, /* 48 - 55 */ |
0, /* 56 */ |
0, /* 57 */ |
0, /* 58 */ |
0, 0, 0, 0, 0, /* 59 - 63 */ |
0, /* 64 */ |
0, /* 65 */ |
0, 0, 0, 0, 0, 0, /* 66 - 71 */ |
0, /* 72 */ |
0, /* 73 */ |
0, /* 74 */ |
0, /* 75 */ |
0, /* 76 */ |
0, /* 77 */ |
0, 0, /* 78 - 79 */ |
0, /* 80 */ |
0, /* 81 */ |
0, 0, 0, 0, 0, 0, /* 82 - 87 */ |
0, /* 88 */ |
0, 0, 0, 0, 0, 0, 0, /* 89 - 95 */ |
0, /* 96 */ |
0, /* 97 */ |
0, 0, 0, 0, 0, 0, /* 98 - 103 */ |
0, /* 104 */ |
0, /* 105 */ |
0, /* 106 */ |
0, /* 107 */ |
0, /* 108 */ |
0, /* 109 */ |
0, 0, /* 110 - 111 */ |
0, /* 112 */ |
0, /* 113 */ |
0} /* 114 */ |
}; |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/nmi.c
0,0 → 1,15
/* |
* $Id: nmi.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
int mach_error_expected = 0; |
void nmi_isr(void) |
{ |
if( mach_error_expected) |
{ |
mach_error_expected = 0; |
} |
else{ |
kkprintf("NMI Interrupt Occured \n"); |
} |
} |
/linkcmds
0,0 → 1,189
/*------------------------------------*/ |
/* rom.ld */ |
/* Last change : 19. 4.95 */ |
/*------------------------------------* |
* To build ROM based i960 image. |
*------------------------------------*/ |
|
/* |
* $Id: linkcmds,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
|
MEMORY |
{ |
config : org = 0xFeffFF30, len = 0xd0 |
eprom : org = 0xfec00000, len = 1024K |
} |
|
|
_bootAddr = 0xa0200000; |
/*_HEAP = 0xA0100000 ; */ |
_rom_ibr_cksum = -(_romStart + _rom_prcb); |
|
SECTIONS |
{ |
prcb : |
{ |
INPUT(rom_ibr.o) |
} > config |
|
/* Only monitor start point and fault handler |
* will live in ROM as far as text is concerned. |
* Only fault table will live in ROM as far as data |
* is concerned. |
*/ |
romCode : |
{ |
/* Make sure that the monitor start point |
* is the first location in EPROM. |
*/ |
rxgen_romld.o(.text) |
/* Procedures to copy code and |
* initialize bss in RAM. |
*/ |
sctns.o(.text) |
/* Make Sure Fault Table (and its handler's data) |
* live here so that they wouldn't get destroyed). |
*/ |
asmfault.o |
ihandler.o |
. = ALIGN(16); |
flttbl.o |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
rom_prcb.o(.data) |
. = ALIGN(16); |
rom_cntrltbl.o(.data) |
. = ALIGN(16); |
intrtbl.o(.data) |
. = ALIGN(16); |
nulsystbl.o(.data) |
. = ALIGN(16); |
/* I need this symbol to know where code which is |
* to be copied reside in ROM. Align it on a 16 |
* boundary. |
*/ |
. = ALIGN(16); |
_codeRomStart = .; |
} > eprom |
|
/* All the rest of the code will live in RAM. |
* Relocation are created as though code resides |
* in RAM, while code is placed right after romCode. |
* This is responsiblity of the ROM monitor to |
* copy code into ROM. |
*/ |
ramCode : AT(ADDR(romCode) + SIZEOF(romCode)) |
{ |
/* RAM-based code section start. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamStart = .; |
/* RAM based fault recovery stuff. |
*/ |
_faultStart = .; |
asmstub.o |
fault.o |
_faultEnd = .; |
/* Check sum to gurantee that |
* the above section wasn't broken. |
*/ |
. = ALIGN(16); |
_faultCheckSum = .; |
. += 4; |
/* Fault Buffer to keep the state of |
* the fauled procedure. |
*/ |
_faultBuffer = .; |
. += 256; |
/* All the rest of the text goes here. |
*/ |
. = ALIGN(16); |
*(.text) |
/* NEW TEST TEST TEST TEST */ |
. = ALIGN (16); |
|
*(.eh_fram) |
. = ALIGN (16); |
|
/* |
* C++ constructors |
*/ |
__CTOR_LIST__ = .; |
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) |
*(.ctors) |
LONG(0) |
__CTOR_END__ = .; |
__DTOR_LIST__ = .; |
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) |
*(.dtors) |
LONG(0) |
__DTOR_END__ = .; |
etext = ALIGN( 0x10 ) ; |
/* END NEW TEST TEST TEST */ |
/* 16 byte aligned PRCB. |
*/ |
. = ALIGN(16); |
prcb.o(.data) |
/* 16 byte aligned Control Table. |
*/ |
. = ALIGN(16); |
cntrltbl.o(.data) |
. = ALIGN(16); |
systbl.o(.data) |
/* All the rest of program defined data goes here. |
*/ |
*(.data) |
/* RAM-based code section end. |
* I need this symbol to know where to copy code |
* at initialization time . |
*/ |
_codeRamEnd = .; |
} > eprom |
|
/* RAM based uninitialized data. |
*/ |
bss (NOLOAD) : |
{ |
/* BSS section start. I need this symbol to |
* zero BSS on initialization. |
*/ |
/* Heap. Aligned on a 64 boundary */ |
/* . = ALIGN(64); |
_heap_initial = .; |
. += 64K;*/ |
/* Supervisor Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_svrStackPtr = .; |
. += 16K; |
/* Interrupt Stack. Aligned on a 16 boundary. |
*/ |
. = ALIGN(16); |
_intStackPtr = .; |
. += 16K; |
/* Program defined BSS. |
*/ |
_bssStart = .; |
_bss_start = .; |
*(.bss) |
/* Program defined COMMON. |
*/ |
*(COMMON) |
_end = .; |
/* BSS section end. I need this symbol to |
* zero BSS on initialization. |
*/ |
_bssEnd = .; |
_bssStart_1 = .; |
_bssEnd_1 = .; |
} > eprom |
|
} |
|
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/asmstub.h
0,0 → 1,38
/*-------------------------------------*/ |
/* asmstub.h */ |
/* Last change : 20. 1.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: asmstub.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _ASMSTUB_H_ |
#define _ASMSTUB_H_ |
|
#include "prcb.h" |
|
/* Reset Processor taking Start Point and Prcb |
* as parameters. |
*/ |
extern void asm_exit(void (* start)(void), struct PRCB * prcb); |
/* Call SYSCTL instruction. |
*/ |
extern void asm_sysctl(unsigned int cmd, unsigned int a1, unsigned int a2); |
/* Alter a bit in the interrupt pending register. |
*/ |
extern void asm_ipend(unsigned int iNmbr, unsigned int toSet); |
/* Alter a bit in the interrupt mask register. |
*/ |
extern void asm_imask(unsigned int iNmbr, unsigned int toSet); |
/* Call MODPC instruction. |
*/ |
extern int asm_modpc(unsigned int val, unsigned int mask); |
/* Change a cached interrupt vector. |
*/ |
extern void asm_ivector(unsigned int vctr, void (* hndl)(void)); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/systbl.h
0,0 → 1,38
/*-------------------------------------*/ |
/* systbl.h */ |
/* Last change : 14.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: systbl.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _SYSTBL_H_ |
#define _SYSTBL_H_ |
|
/* System Procedure. |
*/ |
typedef void (* SysProc)(void); |
/* System Procedures Table. |
*/ |
typedef struct { |
unsigned int reserved[3]; /* Reserved */ |
unsigned int * svrStackPtr; /* Supervisor Stack Pointer Base */ |
unsigned int preserved[8]; /* Preserved */ |
SysProc sysProc[259]; /* System Procedures Entry Points */ |
} SystemTbl; |
/* Type of System Procedure. |
*/ |
#define LOCAL_SP 0x0 |
#define SUPERVISOR_SP 0x2 |
/* Cinvert to System Procedure Type. |
*/ |
#define SP(addr) ((SysProc) (addr)) |
/* System Procedures Table Itself. |
*/ |
extern SystemTbl systemTbl; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/memchnl.h
0,0 → 1,71
/*-------------------------------------*/ |
/* memchnl.h */ |
/* Last change : 16. 5.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: memchnl.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _MEMCHNL_H_ |
#define _MEMCHNL_H_ |
|
/* The following is a dummy for now to be filled in |
as the message passing stuff gets migrated to |
I20 (or other standard ) |
*/ |
|
typedef |
struct memMsg{ |
int * foo; |
} IOTrCBlk, * iotrcb_ptr_t; |
|
typedef void * iotrcb_sgm_t; |
|
/* Interrupt arrived from X processor. |
* This is invoked from low-level interrupt dispatcher. |
*/ |
extern void memChnlIntrFromHost(void); |
/* This IOT's processing is completed. |
* Signal the host, it can take it back. |
*/ |
extern void memChnlIotFinished(IOTrCBlk *); |
/* A fault has just occured. Pass a signal over |
* memory channel. |
*/ |
extern void memChnlI960Fault(void); |
/* IOT handler procedure. |
*/ |
typedef void (* IotHandler)(IOTrCBlk *, int tr_req); |
/* Register handler to process IOT's. |
*/ |
extern void memChnlRegisterHndl(IotHandler); |
/* Intermediate image buffer. |
* Defined in *.ld |
*/ |
extern unsigned int downloadStart[]; |
|
typedef struct { |
int ptr_len; |
iotrcb_ptr_t ptr_loc; |
iotrcb_ptr_t * ptr_crnt; |
iotrcb_sgm_t * sgm_crnt; |
} BufLookupHndl; |
/* Procedures to travel throughout the buffer page list. |
* It should be accomplished as below: |
* ... |
* BufLookupHndl hndl; |
* char * buf; |
* if (memBufLookupInit(& hndl, iot) != 0) { |
* while ((buf = memBufLookupNext(& hndl)) != 0) { |
* ... buf is a buffer page address. |
* } |
* } |
*/ |
extern BufLookupHndl * memBufLookupInit(BufLookupHndl *, IOTrCBlk *); |
extern void * memBufLookupNext(BufLookupHndl *); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/kkprintf.c
0,0 → 1,68
/* |
* a safe version of printf that might be useful for debugging parts that |
* are known to have problems e.g. with printf() e.t.c. |
* |
* $Id: kkprintf.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include <_ansi.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
char kkBuf[1024]; |
/* Routine to do "console" in fully polled mode */ |
void static kkputs( const char *); |
format_string(char * fmt, va_list ap, char * kkBuf); |
#ifdef _HAVE_STDC |
void |
kkprintf (const char *fmt, ...) |
{ |
va_list ap; |
|
va_start (ap, fmt); |
format_string (fmt, *ap+4, kkBuf); |
kkputs(kkBuf); |
va_end (ap); |
} |
void mkvisable() |
{ |
kkputs("Hello"); |
} |
#else |
void |
kkprintf(fmt, va_alist) |
char * fmt; |
va_dcl |
{ |
va_list ap; |
va_start(ap); |
format_string(fmt, ap, kkBuf); |
kkputs(kkBuf); |
va_end(ap); |
} |
#endif |
extern int DBGConsole_make_sync; |
void |
kkputs( const char * buf) |
{ |
volatile unsigned int * consoleOP; |
unsigned char c; |
consoleOP = (unsigned int *) 0x1318; /* Outbound Message 0 */ |
while (( c = *buf++) != 0){ |
while( DBGConsole_make_sync && (*consoleOP != 0)) |
; |
*consoleOP = (unsigned int)c; |
} |
} |
|
|
/* we have got an error during build for 'isatty()' wo/ good reason |
we temporarily use this fix.... |
*/ |
isatty(int fd) |
{ |
return 1; |
} |
|
/Makefile.am
0,0 → 1,54
## |
## $Id: Makefile.am,v 1.2 2001-09-27 11:59:59 chris Exp $ |
## |
|
AUTOMAKE_OPTIONS = foreign 1.4 |
|
VPATH = @srcdir@:@srcdir@/../../../shared |
|
PGM = $(ARCH)/startup.rel |
|
#C_PIECES = bspclean bsplibc bsppost bspstart bootcard main sbrk setvec \ |
# gnatinstallhandler |
C_FILES = bspstart.c cntrltbl.c exit.c fault.c flttbl.c frmstr.c intrtbl.c \ |
kkprintf.c nmi.c nulsystbl.c prcb.c rom_cntrltbl.c rom_ibr.c rom_prcb.c \ |
sctns.c setvec.c systbl.c |
|
H_FILES = asmfault.h asmstub.h cntrltbl.h fault.h faultret.h flttbl.h \ |
frmstr.h i960.h ihandler.h intrtbl.h main.h memchnl.h pmc901_memmap.h \ |
prcb.h rom_ibr.h rommon.h sctns.h systbl.h time.h types.h |
|
S_FILES = asmfault.S asmstub.S ihandler.S rxgen_romld.S |
|
OBJS = $(C_FILES:%.c=$(ARCH)/%.o) $(S_FILES:%.S=$(ARCH)/%.o) |
|
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg |
include $(top_srcdir)/../../../../../../automake/lib.am |
|
# |
# (OPTIONAL) Add local stuff here using += |
# |
|
$(PGM): $(OBJS) |
$(make-rel) |
|
$(PROJECT_RELEASE)/lib/linkcmds: linkcmds |
$(INSTALL_DATA) $< $@ |
|
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile |
|
TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/linkcmds |
|
all-local: $(ARCH) $(OBJS) $(PGM) $(TMPINSTALL_FILES) |
|
.PRECIOUS: $(PGM) |
|
EXTRA_DIST = asmfault.S asmfault.h asmstub.S asmstub.h bspstart.c cntrltbl.c \ |
cntrltbl.h dram.ld exit.c fault.c fault.h faultret.h flttbl.c flttbl.h \ |
frmstr.c frmstr.h i960.h ihandler.S ihandler.h intrtbl.c intrtbl.h \ |
kkprintf.c linkcmds main.h memchnl.h nmi.c nulsystbl.c pmc901_memmap.h \ |
prcb.c prcb.h rom.ld rom_cntrltbl.c rom_ibr.c rom_ibr.h rom_prcb.c \ |
rommon.h rxgen_romld.S sctns.c sctns.h setvec.c systbl.c systbl.h time.h \ |
types.h |
|
include $(top_srcdir)/../../../../../../automake/local.am |
/main.h
0,0 → 1,28
/*-------------------------------------*/ |
/* main.h */ |
/* Last change : 2. 2.95 */ |
/*-------------------------------------*/ |
/* |
* $Id: main.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _MAIN_H_ |
#define _MAIN_H_ |
|
/* ROM monitor main function(s). |
* Gets control from rommon.s. |
*/ |
extern void romMain(void); |
extern void romFaultMain(void); |
extern void romTestMain(void); |
|
extern char * mainRevisionStr(void); |
extern char * mainBuildStr(void); |
|
extern unsigned int bootAddr[]; |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/rom_ibr.c
0,0 → 1,34
/*-------------------------------------*/ |
/* rom_ibr.h */ |
/* Last change : 23. 1.95 */ |
/*-------------------------------------*/\ |
/* |
* $Id: rom_ibr.c,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#include "rom_ibr.h" |
#include "prcb.h" |
#include "cntrltbl.h" |
#include <i960RP.h> |
#include "../include/rxgen960_config.h" |
/*-------------------------------------*/ |
extern void romStart(void); |
|
|
struct IBR rom_ibr = { |
{((REGION_BOOT_CONFIG) & 0xff), /* Initial Bus Configuration */ |
((REGION_BOOT_CONFIG) >> 8) & 0xff, |
((REGION_BOOT_CONFIG) >> 16) & 0xff, |
((REGION_BOOT_CONFIG) >> 24) & 0xff}, |
romStart, /* Start Point */ |
& rom_prcb, /* PRCB */ |
{-2, /* CheckSum */ |
0, |
0, |
0, |
0, |
(unsigned int) rom_ibr_cksum} |
}; |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/ihandler.h
0,0 → 1,24
/*-------------------------------------*/ |
/* ihandler.h */ |
/* Last change : 12.10.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: ihandler.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _IHANDLER_H_ |
#define _IHANDLER_H_ |
|
/* Interrupt Handler for NMI. |
*/ |
extern void nmiHandler(void); |
/* Interrupt Handlers for Dedicated Interrupts. |
*/ |
extern void intr5Handler(void); |
extern void intr6Handler(void); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/faultret.h
0,0 → 1,21
/*-------------------------------------*/ |
/* faultret.h */ |
/* Last change : 3.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: faultret.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _FAULTRET_H_ |
#define _FAULTRET_H_ |
|
/* Return to the point where fault happened. |
* Fault state keeps all registers. |
*/ |
extern void faultRet(unsigned int * faultState); |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
|
/i960.h
0,0 → 1,34
/*-------------------------------------*/ |
/* i960.h */ |
/* Last change : 3.11.94 */ |
/*-------------------------------------*/ |
/* |
* $Id: i960.h,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
#ifndef _I960_H_ |
#define _I960_H_ |
|
#define REGISTER_SIZE 4 |
#define NUM_REGS 40 |
|
#define R0_REGNUM 0 /* First local register */ |
#define SP_REGNUM 1 /* Contains address of top of stack */ |
#define RIP_REGNUM 2 /* Return instruction pointer (local r2) */ |
#define R15_REGNUM 15 /* Last local register */ |
#define G0_REGNUM 16 /* First global register */ |
#define G13_REGNUM 29 /* g13 - holds struct return address */ |
#define G14_REGNUM 30 /* g14 - ptr to arg block / leafproc return address */ |
#define FP_REGNUM 31 /* Contains address of executing stack frame */ |
#define PCW_REGNUM 32 /* process control word */ |
#define ACW_REGNUM 33 /* arithmetic control word */ |
#define TCW_REGNUM 34 /* trace control word */ |
#define IP_REGNUM 35 /* instruction pointer */ |
#define FP0_REGNUM 36 /* First floating point register */ |
|
#define REGISTER_BYTES ((36*4) + (4*10)) |
|
#endif |
/*-------------*/ |
/* End of file */ |
/*-------------*/ |
/asmfault.S
0,0 → 1,48
/* |
* $Id: asmfault.S,v 1.2 2001-09-27 11:59:59 chris Exp $ |
*/ |
|
/* |
* asmfault.s |
* Last change : 31. 1.95 |
*/ |
|
.text |
.globl _faultHndlEntry |
|
.text |
|
_faultHndlEntry : |
/* Raise priority. */ |
ldconst 0x1F0000, r4 |
ldconst 0xFFFFFFFF, r5 |
modpc r4, r4, r5 |
/* Where to keep state of the faulted code. */ |
ldconst _faultBuffer, r3 |
/* Save global registers. */ |
stq g0, 64+0(r3) |
stq g4, 64+16(r3) |
stq g8, 64+32(r3) |
stt g12, 64+48(r3) |
/* Faulted code's fp (g15) is our pfp. */ |
st pfp, 64+60(r3) |
/* Make sure locals are in stack. */ |
flushreg |
/* g3 = & previosFrame[0] */ |
andnot 0xF, pfp, g3 |
/* Save local registers of faulted procedure. */ |
ldq 0(g3), r4 |
stq r4, 0(r3) |
ldq 16(g3), r4 |
stq r4, 16(r3) |
ldq 32(g3), r4 |
stq r4, 32(r3) |
ldq 48(g3), r4 |
stq r4, 48(r3) |
/* To handling. */ |
mov fp, g0 |
mov r3, g1 |
callx _faultTblHandler |
/* This point will never be reached ... */ |
|
/* End of file */ |