FreeNOS
ARMException.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <MemoryBlock.h>
19 #include "ARMException.h"
20 #include "ARMCore.h"
21 #include <Log.h>
22 
24 
26  : m_vecTable(base)
27 {
29 
30  // First enable low interrupt vector base to allow re-mapping
31  u32 v = sysctrl_read();
32  v &= ~(1 << 13);
33  sysctrl_write(v);
34 
35  // Remap to requested base address
36  vbar_set(base);
37 }
38 
41  ARMException::Handler handler)
42 {
43  ((Address *) &handlerTable)[vector] = (Address) handler;
44  return Success;
45 }
ARMException.h
handlerTable
Address handlerTable
Definition: ARMException.cpp:23
MemoryBlock::copy
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Definition: MemoryBlock.cpp:36
ARM_EX_VECTAB_SIZE
#define ARM_EX_VECTAB_SIZE
Size of the ARM exception vector table in bytes.
Definition: ARMException.h:39
ARMCore.h
Address
unsigned long Address
A memory address.
Definition: Types.h:131
MemoryBlock.h
ARMException::Success
@ Success
Definition: ARMException.h:68
vbar_set
#define vbar_set(addr)
Change Vector Base Address (VBAR)
Definition: ARMCore.h:121
ARMException::ARMException
ARMException(Address base)
Constructor.
Definition: ARMException.cpp:25
Log.h
ARMException::Result
Result
Result codes.
Definition: ARMException.h:66
sysctrl_write
#define sysctrl_write(val)
Write System Control register.
Definition: ARMCore.h:133
ARMException::install
Result install(ExceptionType vector, Handler handler)
Install an exception handler.
Definition: ARMException.cpp:39
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
sysctrl_read
#define sysctrl_read()
Read System Control register.
Definition: ARMCore.h:127
ARMException::Handler
void Handler(struct CPUState state)
Function which is called when the CPU is interrupted.
Definition: ARMException.h:78
ARMException::m_vecTable
Address m_vecTable
ARM exception vector jump table.
Definition: ARMException.h:113
vecTable
Address vecTable[]
ARMException::ExceptionType
ExceptionType
ARM exception types.
Definition: ARMException.h:51