]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/h8300/generic/libs/misc/excptvec.c
73e2569599645674d6def368cc98d8b68547a492
[sysless.git] / arch / h8300 / generic / libs / misc / excptvec.c
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware  
4  
5   excptvec.c - exception and interrupt table manipulation for
6                H8S 2633 - uses part of internal SRAM memory
7                to overlay beginning of flash memory -> this
8                enables to change interrupt vectors for
9                applicatons loaded into RAM
10  
11   Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
12             (C) 2002 by PiKRON Ltd. http://www.pikron.com
13
14  *******************************************************************/
15
16 #include <system_def.h>
17 #include <cpu_def.h>
18 #include <mcu_regs.h>
19 #include <string.h>
20
21 void *excptvec_get(int vectnum)
22 {
23   __u32 *pvect;
24   pvect=(__u32*)((__u32)(vectnum<<2)+0);
25   return (void*)*pvect;
26 }
27
28
29 void *excptvec_set(int vectnum,void *vect)
30 {
31   __u32 *pvect;
32   void *ovect;
33   pvect=(__u32*)((__u32)(vectnum<<2)+0);
34   ovect=(void*)*pvect;
35   *pvect=(__u32)vect;
36   return ovect;
37 }
38
39
40 int excptvec_initfill(void *fill_vect, int force_all)
41 {
42   __u32 *pvect;
43   int i;
44   __u32 l;
45
46   if((*FLM_RAMER&(RAMER_RAMSm|RAMER_RAMxm))!=RAMER_RAMSm){
47     memcpy((void*)0xffd000,(void*)0,0x1000);
48     *FLM_RAMER=RAMER_RAMSm+0;
49   }
50   
51   for(i=0,pvect=0;i<128;i++,pvect++){
52     l=(__u32)*pvect;
53     if((l==0)||(l==0xffffffff)||force_all)
54       *pvect=(__u32)fill_vect;
55   }
56   
57   return 0;
58 }
59