checkpoint -- reorganizing and fixing errors
This commit is contained in:
parent
8c17fc36d1
commit
c4f6aa459e
2
Makefile
2
Makefile
|
@ -40,7 +40,7 @@ include $(TOPDIR)/config.mk
|
|||
AOBJS =
|
||||
COBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
|
||||
#TESTS = $(wildcard tests/*.c)
|
||||
TESTS = tests/blink-red.c
|
||||
TESTS = tests/blink-red.c #tests/nvm-read.c
|
||||
TARGETS = $(patsubst %.c,%.o,$(TESTS))
|
||||
|
||||
# Add GCC lib
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
#include "nvm.h"
|
||||
|
||||
volatile nvmErr_t (*nvm_detect)(nvmInterface_t nvmInterface,nvmType_t* pNvmType) = 0x00006cb9;
|
||||
volatile nvmErr_t (*nvm_read)(nvmInterface_t nvmInterface , nvmType_t nvmType , void *pDest, uint32_t address, uint32_t numBytes) = 0x00006d69;
|
||||
volatile nvmErr_t (*nvm_write)(nvmInterface_t nvmInterface, nvmType_t nvmType ,void *pSrc, uint32_t address, uint32_t numBytes) = 0x00006ec5;
|
||||
volatile nvmErr_t (*nvm_erase)(nvmInterface_t nvmInterface, nvmType_t nvmType ,uint32_t sectorBitfield) = 0x00006e05;
|
||||
volatile void(*nvm_setsvar)(uint32_t zero_for_awesome) = 0x00007085;
|
||||
volatile nvmErr_t (*nvm_detect)
|
||||
(nvmInterface_t nvmInterface,nvmType_t* pNvmType)
|
||||
= (void *) 0x00006cb9;
|
||||
|
||||
volatile nvmErr_t (*nvm_read)
|
||||
(nvmInterface_t nvmInterface , nvmType_t nvmType , void *pDest, uint32_t address, uint32_t numBytes)
|
||||
= (void *) 0x00006d69;
|
||||
|
||||
volatile nvmErr_t (*nvm_write)
|
||||
(nvmInterface_t nvmInterface, nvmType_t nvmType ,void *pSrc, uint32_t address, uint32_t numBytes)
|
||||
= (void *) 0x00006ec5;
|
||||
|
||||
volatile nvmErr_t (*nvm_erase)
|
||||
(nvmInterface_t nvmInterface, nvmType_t nvmType ,uint32_t sectorBitfield)
|
||||
= (void*) 0x00006e05;
|
||||
|
||||
volatile void(*nvm_setsvar)
|
||||
(uint32_t zero_for_awesome)
|
||||
= (void *)0x00007085;
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* $RCSfile: interrupt-utils.c,v $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* This module provides the interface routines for setting up and
|
||||
* controlling the various interrupt modes present on the ARM processor.
|
||||
* Copyright 2004, R O SoftWare
|
||||
* No guarantees, warrantees, or promises, implied or otherwise.
|
||||
* May be used for hobby or commercial purposes provided copyright
|
||||
* notice remains intact.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "interrupt-utils.h"
|
||||
|
||||
#define IRQ_MASK 0x00000080
|
||||
#define FIQ_MASK 0x00000040
|
||||
#define INT_MASK (IRQ_MASK | FIQ_MASK)
|
||||
|
||||
unsigned __get_cpsr(void)
|
||||
{
|
||||
unsigned long retval;
|
||||
asm volatile (
|
||||
".code 32;"
|
||||
"mrs %0, cpsr;"
|
||||
".code 16;"
|
||||
: "=r" (retval) :
|
||||
);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void __set_cpsr(unsigned val)
|
||||
{
|
||||
asm volatile (
|
||||
".code 32;"
|
||||
"msr cpsr_c, %0;"
|
||||
".code 16;"
|
||||
: : "r" (val)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unsigned disableIRQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr | IRQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned restoreIRQ(unsigned oldCPSR)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned enableIRQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr & ~IRQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned disableFIQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr | FIQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned restoreFIQ(unsigned oldCPSR)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK));
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned enableFIQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr & ~FIQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include "embedded_types.h"
|
||||
#include <mc1322x.h>
|
||||
#include <nvm.h>
|
||||
#include "maca.h"
|
||||
#include "nvm.h"
|
||||
|
||||
#define reg(x) (*(volatile uint32_t *)(x))
|
||||
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
#include "sys-interrupt.h"
|
||||
#include "interrupt-utils.h"
|
||||
|
||||
#include "embedded_types.h"
|
||||
|
||||
#define ATTR
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
static SystemInterruptHandler *handlers = NULL;
|
||||
|
||||
static void
|
||||
system_int_safe (void) __attribute__((noinline));
|
||||
|
||||
static void
|
||||
system_int_safe (void)
|
||||
{
|
||||
SystemInterruptHandler *h;
|
||||
h = handlers;
|
||||
while (h) {
|
||||
if (h->handler()) break;
|
||||
h = h->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void NACKEDFUNC ATTR
|
||||
system_int (void) /* System Interrupt Handler */
|
||||
{
|
||||
ISR_ENTRY();
|
||||
system_int_safe();
|
||||
ISR_EXIT();
|
||||
}
|
||||
|
||||
static unsigned int enabled = 0; /* Number of times the system
|
||||
interrupt has been enabled */
|
||||
|
||||
#define INTCNTL 0x80020000
|
||||
#define DIS_INT *((volatile uint32_t *)INTCNTL) = 3 << 19;
|
||||
#define EN_INT if (enabled > 0) *((volatile uint32_t *)INTCNTL) = 0;
|
||||
|
||||
void
|
||||
sys_interrupt_enable()
|
||||
{
|
||||
if (enabled++ == 0) {
|
||||
/* Enable */
|
||||
EN_INT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sys_interrupt_disable()
|
||||
{
|
||||
if (--enabled == 0) {
|
||||
DIS_INT;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sys_interrupt_append_handler(SystemInterruptHandler *handler)
|
||||
{
|
||||
SystemInterruptHandler **h = &handlers;
|
||||
while(*h) {
|
||||
h = &(*h)->next;
|
||||
}
|
||||
DIS_INT;
|
||||
*h = handler;
|
||||
handler->next = NULL;
|
||||
EN_INT;
|
||||
}
|
||||
|
||||
void
|
||||
sys_interrupt_prepend_handler(SystemInterruptHandler *handler)
|
||||
{
|
||||
DIS_INT;
|
||||
handler->next = handlers;
|
||||
handlers = handler;
|
||||
EN_INT;
|
||||
}
|
||||
|
||||
void
|
||||
sys_interrupt_remove_handler(SystemInterruptHandler *handler)
|
||||
{
|
||||
SystemInterruptHandler **h = &handlers;
|
||||
while(*h) {
|
||||
if (*h == handler) {
|
||||
DIS_INT;
|
||||
*h = handler->next;
|
||||
EN_INT;
|
||||
break;
|
||||
}
|
||||
h = &(*h)->next;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue