Resolve link problems with psim irq-server

Add IRQ support components needed by new BSD code.
This commit is contained in:
Jennifer Averett
2012-03-30 08:41:15 -05:00
24 changed files with 825 additions and 191 deletions

View File

@@ -25,10 +25,13 @@ noinst_PROGRAMS =
SUBDIRS = . tools
include_bsp_HEADERS = ../../i386/shared/irq/irq.h \
../../i386/shared/irq/irq_asm.h ../../i386/shared/comm/tty_drv.h \
../../shared/include/irq-generic.h \
../../shared/include/irq-info.h
include_bsp_HEADERS = ../../i386/shared/irq/irq.h
include_bsp_HEADERS += ../../i386/shared/irq/irq_asm.h
include_bsp_HEADERS += ../../i386/shared/comm/tty_drv.h
include_bsp_HEADERS += ../../shared/include/irq-generic.h
include_bsp_HEADERS += ../../shared/include/irq-info.h
include_bsp_HEADERS += console/rtd316.h
include_bsp_HEADERS += console/exar17d15x.h
if HAS_SMP
include_bsp_HEADERS += ../../i386/shared/irq/apic.h
@@ -63,30 +66,49 @@ noinst_LIBRARIES += libbsp.a
libbsp_a_SOURCES =
# clock
libbsp_a_SOURCES += clock/ckinit.c clock/todcfg.c ../../shared/tod.c
libbsp_a_SOURCES += clock/ckinit.c
libbsp_a_SOURCES += clock/todcfg.c
libbsp_a_SOURCES += ../../shared/tod.c
libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
include_rtemsdir = $(includedir)/rtems
include_rtems_HEADERS = console/keyboard.h console/kd.h console/ps2_drv.h \
../../shared/console_private.h console/vgacons.h
include_rtems_HEADERS = console/keyboard.h
include_rtems_HEADERS += console/kd.h
include_rtems_HEADERS += console/ps2_drv.h
include_rtems_HEADERS += ../../shared/console_private.h
include_rtems_HEADERS += console/vgacons.h
include_HEADERS += ../../i386/shared/comm/i386_io.h
# console
libbsp_a_SOURCES += console/inch.c console/outch.c \
console/defkeymap.c console/fb_vga.c console/keyboard.c \
console/pc_keyb.c console/ps2_mouse.c \
console/vgainit.c console/vt.c console/videoAsm.S \
console/kbd_parser.c console/serial_mouse_config.c \
../../i386/shared/comm/uart.c ../../i386/shared/comm/tty_drv.c \
../../shared/console.c console/console_select.c \
../../shared/console_read.c ../../shared/console_write.c \
console/console_control.c console/conscfg.c console/printk_support.c \
console/vgacons.c
libbsp_a_SOURCES += console/inch.c
libbsp_a_SOURCES += console/outch.c
libbsp_a_SOURCES += console/defkeymap.c
libbsp_a_SOURCES += console/fb_vga.c
libbsp_a_SOURCES += console/keyboard.c
libbsp_a_SOURCES += console/pc_keyb.c
libbsp_a_SOURCES += console/ps2_mouse.c
libbsp_a_SOURCES += console/vgainit.c
libbsp_a_SOURCES += console/vt.c
libbsp_a_SOURCES += console/videoAsm.S
libbsp_a_SOURCES += console/kbd_parser.c
libbsp_a_SOURCES += console/serial_mouse_config.c
libbsp_a_SOURCES += ../../i386/shared/comm/uart.c
libbsp_a_SOURCES += ../../i386/shared/comm/tty_drv.c
libbsp_a_SOURCES += ../../shared/console.c
libbsp_a_SOURCES += console/console_select.c
libbsp_a_SOURCES += ../../shared/console_read.c
libbsp_a_SOURCES += ../../shared/console_write.c
libbsp_a_SOURCES += console/console_control.c
libbsp_a_SOURCES += console/conscfg.c
libbsp_a_SOURCES += console/printk_support.c
libbsp_a_SOURCES += console/vgacons.c
libbsp_a_SOURCES += console/exar17d15x.c
libbsp_a_SOURCES += console/rtd316.c
# gdb
libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub.c \
../../i386/shared/comm/i386-stub-glue.c \
../../i386/shared/comm/gdb_glue.c
libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub.c
libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub-glue.c
libbsp_a_SOURCES += ../../i386/shared/comm/gdb_glue.c
# gnat
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
@@ -98,19 +120,29 @@ libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c \
include_HEADERS += ../../i386/shared/comm/uart.h
# startup
libbsp_a_SOURCES += ../../shared/bsplibc.c ../../shared/bsppost.c \
../../shared/bsppredriverhook.c startup/bspgetworkarea.c \
../../shared/bsppretaskinghook.c startup/bspstart.c startup/bspcmdline.c \
../../shared/bspclean.c startup/bspreset.c ../../i386/shared/irq/idt.c \
../../i386/shared/irq/irq.c ../../i386/shared/irq/irq_init.c \
../../shared/bootcard.c ../../shared/bspinit.c ../../shared/sbrk.c \
startup/ldsegs.S ../../i386/shared/irq/irq_asm.S \
../../shared/src/irq-default-handler.c \
../../shared/src/irq-generic.c \
../../shared/src/irq-legacy.c \
../../shared/src/irq-info.c \
../../shared/src/irq-shell.c \
../../shared/src/irq-server.c
libbsp_a_SOURCES += ../../shared/bsplibc.c
libbsp_a_SOURCES += ../../shared/bsppost.c
libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
libbsp_a_SOURCES += startup/bspgetworkarea.c
libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
libbsp_a_SOURCES += startup/bspstart.c
libbsp_a_SOURCES += startup/bspcmdline.c
libbsp_a_SOURCES += ../../shared/bspclean.c
libbsp_a_SOURCES += startup/bspreset.c
libbsp_a_SOURCES += ../../i386/shared/irq/idt.c
libbsp_a_SOURCES += ../../i386/shared/irq/irq.c
libbsp_a_SOURCES += ../../i386/shared/irq/irq_init.c
libbsp_a_SOURCES += ../../shared/bootcard.c
libbsp_a_SOURCES += ../../shared/bspinit.c
libbsp_a_SOURCES += ../../shared/sbrk.c
libbsp_a_SOURCES += startup/ldsegs.S
libbsp_a_SOURCES += ../../i386/shared/irq/irq_asm.S
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
libbsp_a_SOURCES += ../../shared/src/irq-server.c
# timer
libbsp_a_SOURCES += timer/timer.c timer/timerisr.S
@@ -149,7 +181,8 @@ include_HEADERS += include/wd80x3.h
wd8003_CPPFLAGS = -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
noinst_PROGRAMS += wd8003.rel
wd8003_rel_SOURCES = wd8003/wd8003.c include/wd80x3.h
wd8003_rel_SOURCES = wd8003/wd8003.c
wd8003_rel_SOURCES += include/wd80x3.h
wd8003_rel_CPPFLAGS = $(AM_CPPFLAGS) $(wd8003_CPPFLAGS)
wd8003_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
@@ -157,14 +190,17 @@ endif
if HAS_NETWORKING
3c509_CPPFLAGS = -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
noinst_PROGRAMS += 3c509.rel
3c509_rel_SOURCES = 3c509/3c509.c 3c509/3c509.h 3c509/elink.c 3c509/elink.h
3c509_rel_SOURCES = 3c509/3c509.c
3c509_rel_SOURCES += 3c509/3c509.h
3c509_rel_SOURCES += 3c509/elink.c
3c509_rel_SOURCES += 3c509/elink.h
3c509_rel_CPPFLAGS = $(AM_CPPFLAGS) $(3c509_CPPFLAGS)
3c509_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel \
../../../libcpu/@RTEMS_CPU@/page.rel \
../../../libcpu/@RTEMS_CPU@/score.rel
libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/page.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/score.rel
if HAS_SMP
libbsp_a_LIBADD += appstart.$(OBJEXT)
@@ -173,10 +209,16 @@ endif
# We only build the Network library if HAS_NETWORKING was defined
# dec21140 is supported via libchip
if HAS_NETWORKING
libbsp_a_LIBADD += ne2000.rel wd8003.rel 3c509.rel
libbsp_a_LIBADD += ne2000.rel
libbsp_a_LIBADD += wd8003.rel
libbsp_a_LIBADD += 3c509.rel
endif
EXTRA_DIST += HOWTO README.dec21140 STATUS times_i486dx times_p5
EXTRA_DIST += HOWTO
EXTRA_DIST += README.dec21140
EXTRA_DIST += STATUS
EXTRA_DIST += times_i486dx
EXTRA_DIST += times_p5
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,224 @@
/**
* @file
*
* @brief Driver for Exar XR17D15x Multiport UARTs
*
* This driver supports 2, 4 or 8 port Exar parts which are NS16550
* compatible.
*/
/*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <bsp.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <rtems/termiostypes.h>
#include <libchip/serial.h>
#include <libchip/ns16550.h>
#include <rtems/bspIo.h>
#include <rtems/pci.h>
#include <bsp/exar17d15x.h>
#include "../../../shared/console_private.h"
#define MAX_BOARDS 4
/*
* This is the rate for the clock internal to the parts.
*/
#define EXAR_CLOCK_RATE (921600*16)
/*
* Supported PCI Ids
*/
#define PCI_VENDOR_ID_EXAR 0x13A8
#define PCI_VENDOR_ID_EXAR_XR17D158 0x0158
#define PCI_VENDOR_ID_EXAR_XR17D154 0x0154
#define PCI_VENDOR_ID_EXAR_XR17D152 0x0152
/*
* Structure to manage each instance found.
*/
typedef struct {
uint16_t vendor;
uint16_t device;
uint8_t ports;
} exar_parts_t;
static exar_parts_t Supported[] = {
{ PCI_VENDOR_ID_EXAR, PCI_VENDOR_ID_EXAR_XR17D158, 8 },
{ PCI_VENDOR_ID_EXAR, PCI_VENDOR_ID_EXAR_XR17D154, 4 },
{ PCI_VENDOR_ID_EXAR, PCI_VENDOR_ID_EXAR_XR17D152, 2 },
{ 0, 0, 0 }
};
/*
* Information saved from PCI scan
*/
typedef struct {
bool found;
uint32_t base;
uint8_t irq;
uint8_t bus;
uint8_t slot;
uint8_t ports;
} exar17d15x_conf_t;
/*
* Register Access Routines
*/
static uint8_t xr17d15x_get_register(uint32_t addr, uint8_t i)
{
uint8_t val = 0;
volatile uint8_t *reg = (volatile uint8_t *)(addr + i);
val = *reg;
// printk( "RD %p -> 0x%02x\n", reg, val );
return val;
}
static void xr17d15x_set_register(uint32_t addr, uint8_t i, uint8_t val)
{
volatile uint8_t *reg = (volatile uint8_t *)(addr + i);
// printk( "WR %p <- 0x%02x\n", reg, val );
*reg = val;
}
rtems_device_driver exar17d15x_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor_arg,
void *arg
)
{
// int pbus, pdev, pfun;
exar17d15x_conf_t conf[MAX_BOARDS];
int boards = 0;
int b = 0;
int p;
console_tbl *ports;
console_tbl *port_p;
int pbus;
int pdev;
int pfun;
int status;
int instance;
int i;
int total_ports = 0;
for ( b=0 ; b<MAX_BOARDS ; b++ ) {
conf[b].found = false;
}
/*
* Scan for Serial port boards
*
* NOTE: There appear to be Exar parts with 2 and 4 ports which would
* be easy to support. Just change the hard-coded 8 ports per
* board to variable and adjust.
*
* NOTE: There are likely other board vendors which could be supported
* by this.
*/
for ( instance=0 ; instance < MAX_BOARDS ; instance++ ) {
for ( i=0 ; Supported[i].ports != 0 ; i++ ) {
status = pci_find_device(
Supported[i].vendor,
Supported[i].device,
instance,
&pbus,
&pdev,
&pfun
);
if ( status == PCIB_ERR_SUCCESS ) {
boards++;
conf[instance].found = true;
conf[instance].ports = Supported[i].ports;
total_ports += conf[instance].ports;
break;
}
}
if ( status != PCIB_ERR_SUCCESS )
continue;
pci_read_config_byte(
pbus,
pdev,
pfun,
PCI_INTERRUPT_LINE,
&conf[instance].irq
);
pci_read_config_dword(
pbus,
pdev,
pfun,
PCI_BASE_ADDRESS_0,
&conf[instance].base
);
printk(
"Found Exar 17D15x %d at 0x%08x IRQ %d with %d ports\n",
instance,
conf[instance].base,
conf[instance].irq,
conf[instance].ports
);
}
/*
* Now allocate array of device structures and fill them in
*/
ports = calloc( total_ports, sizeof( console_tbl ) );
port_p = ports;
for ( b=0 ; b<MAX_BOARDS ; b++ ) {
if ( conf[b].found == false )
continue;
for ( p=0 ; p<conf[b].ports ; p++ ) {
char name[32];
sprintf( name, "/dev/exar17d15x_%d_%d", b, p );
//printk("Found %s\n", name );
port_p->sDeviceName = strdup( name );
port_p->deviceType = SERIAL_NS16550;
#if 1
port_p->pDeviceFns = &ns16550_fns_polled;
#else
port_p->pDeviceFns = &ns16550_fns;
#endif
port_p->deviceProbe = NULL;
port_p->pDeviceFlow = NULL;
port_p->ulMargin = 16;
port_p->ulHysteresis = 8;
port_p->pDeviceParams = (void *) 9600;
port_p->ulCtrlPort1 = conf[b].base + (p * 0x0200);
port_p->ulCtrlPort2 = 0; /* NA */
port_p->ulDataPort = 0; /* NA */
port_p->getRegister = xr17d15x_get_register;
port_p->setRegister = xr17d15x_set_register;
port_p->getData = NULL; /* NA */
port_p->setData = NULL; /* NA */
port_p->ulClock = EXAR_CLOCK_RATE;
port_p->ulIntVector = conf[b].irq;
port_p++;
} /* end ports */
} /* end boards */
/*
* Register the devices
*/
if ( boards )
console_register_devices( ports, total_ports );
return RTEMS_SUCCESSFUL;
}

View File

@@ -0,0 +1,54 @@
/**
* @file bsp/exar17d15x.h
*
* This file provides the interface to the Exar Multiport
* PCI UART controller.
*/
/*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef _BSP_EXAR17D15X__h
#define _BSP_EXAR17D15X__h
#ifdef __cplusplus
extern "C" {
#endif
/**
* This macro defines the standard device driver table entry for
* a console device driver.
*/
#define EXAR17D15X_DRIVER_TABLE_ENTRY \
{ exar17d15x_initialize, NULL, NULL, NULL, NULL, NULL }
/**
* @brief Exar 17D15x Initialization Entry Point
*
* This method initializes the Exar XR17D15x device driver.
*
* @param[in] major is the device driver major number
* @param[in] minor is the device driver minor number
* @param[in] arg is the parameters to this call
*
* @return This method returns RTEMS_SUCCESSFUL when
* the device driver is successfully initialized.
*/
rtems_device_driver exar17d15x_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
);
#ifdef __cplusplus
}
#endif
#endif
/* end of include file */

View File

@@ -0,0 +1,108 @@
/**
* @file
*
* @brief Driver for RTD316 ISA SCC Board
*
* The RTD316 has a single Z85C30.
*/
/*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <bsp.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <rtems/termiostypes.h>
#include <libchip/serial.h>
#include <libchip/z85c30.h>
#include <rtems/bspIo.h>
#include <bsp/rtd316.h>
#include <rtems/score/i386.h>
#define RTD_CLOCK_RATE (460800 * 32)
uint8_t rtd316_com_get_register(uint32_t addr, uint8_t reg)
{
register uint8_t val = 0;
outport_byte( addr, reg );
/* It appears the no delay is needed between the accesses. */
inport_byte( addr, val );
return val;
}
void rtd316_com_set_register(uint32_t addr,uint8_t reg, uint8_t val)
{
outport_byte( addr, reg );
/* It appears the no delay is needed between the accesses. */
outport_byte( addr, val );
}
rtems_device_driver rtd316_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor_arg,
void *arg
)
{
int p;
console_tbl *ports;
console_tbl *port_p;
/*
* Now allocate array of device structures and fill them in
*/
ports = calloc( 2, sizeof( console_tbl ) );
port_p = ports;
for ( p=0 ; p<2 ; p++ ) {
char name[32];
sprintf( name, "/dev/rtd316_1_%d", p );
printk("Found %s\n", name );
port_p->sDeviceName = strdup( name );
port_p->deviceType = SERIAL_Z85C30;
#if 0
port_p->pDeviceFns = &z85c30_fns_polled;
#else
port_p->pDeviceFns = &z85c30_fns;
#endif
port_p->deviceProbe = NULL;
port_p->pDeviceFlow = NULL;
port_p->ulMargin = 16;
port_p->ulHysteresis = 8;
port_p->pDeviceParams = (void *) 9600;
port_p->getRegister = rtd316_com_get_register;
port_p->setRegister = rtd316_com_set_register;
port_p->getData = NULL;
port_p->setData = NULL;
port_p->ulClock = RTD_CLOCK_RATE;
port_p->ulIntVector = 9;
if ( p==0 ) {
port_p->ulDataPort = 0;
port_p->ulCtrlPort1 = 0x340;
port_p->ulCtrlPort2 = 0x341;
} else {
port_p->ulDataPort = 1;
port_p->ulCtrlPort1 = 0x342;
port_p->ulCtrlPort2 = 0x343;
}
port_p++;
} /* end ports */
/*
* Register the devices
*/
console_register_devices( ports, 2 );
return RTEMS_SUCCESSFUL;
}

View File

@@ -0,0 +1,56 @@
/**
* @file bsp/rtd316.h
*
* @brief RTD316 Driver Interface Definition
*
* This file provides the interface to the RTD316 Dual
* serial port utility module.
*/
/*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef _BSP_RTD_316_h
#define _BSP_RTD_316_h
#ifdef __cplusplus
extern "C" {
#endif
/**
* This macro defines the standard device driver table entry for
* a console device driver.
*/
#define RTD316_DRIVER_TABLE_ENTRY \
{ rtd316_initialize, NULL, NULL, NULL, NULL, NULL }
/**
* @brief RTD316 Initialization Entry Point
*
* This method initializes the RTD316 device driver.
*
* @param[in] major is the device driver major number
* @param[in] minor is the device driver minor number
* @param[in] arg is the parameters to this call
*
* @return This method returns RTEMS_SUCCESSFUL when
* the device driver is successfully initialized.
*/
rtems_device_driver rtd316_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
);
#ifdef __cplusplus
}
#endif
#endif
/* end of include file */

View File

@@ -73,6 +73,14 @@ $(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INC
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
$(PROJECT_INCLUDE)/bsp/rtd316.h: console/rtd316.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/rtd316.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/rtd316.h
$(PROJECT_INCLUDE)/bsp/exar17d15x.h: console/exar17d15x.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/exar17d15x.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/exar17d15x.h
if HAS_SMP
$(PROJECT_INCLUDE)/bsp/apic.h: ../../i386/shared/irq/apic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/apic.h

View File

@@ -50,8 +50,9 @@ libbsp_a_SOURCES += console/console-io.c console/consupp.S
# irq
include_bsp_HEADERS = irq/irq.h ../shared/openpic/openpic.h \
../../shared/include/irq-generic.h
libbsp_a_SOURCES += irq/irq_init.c ../shared/irq/openpic_i8259_irq.c ../shared/openpic/openpic.c \
../../shared/src/irq-server.c
libbsp_a_SOURCES += irq/irq_init.c ../shared/irq/openpic_i8259_irq.c \
../shared/openpic/openpic.c ../../shared/src/irq-server.c \
../../shared/src/irq-generic.c ../../shared/src/irq-default-handler.c
EXTRA_DIST = vectors/README
# vectors

View File

@@ -89,3 +89,34 @@ void BSP_rtems_irq_mng_init(unsigned cpuId)
printk("RTEMS IRQ management is now operationnal\n");
#endif
}
int psim_exception_handler( BSP_Exception_frame *frame, unsigned exception_number)
{
BSP_panic("Unexpected interrupt occured");
return 0;
}
/*
* functions to enable/disable a source at the ipic
*/
rtems_status_code bsp_interrupt_vector_enable( rtems_vector_number irqnum)
{
/* FIXME: do something */
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_vector_disable( rtems_vector_number irqnum)
{
/* FIXME: do something */
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_facility_initialize(void)
{
/* Install exception handler */
if (ppc_exc_set_handler( ASM_EXT_VECTOR, psim_exception_handler)) {
return RTEMS_IO_ERROR;
}
return RTEMS_SUCCESSFUL;
}

View File

@@ -81,6 +81,10 @@ $(PROJECT_INCLUDE)/bsp/openpic.h: ../shared/openpic/openpic.h $(PROJECT_INCLUDE)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/openpic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/openpic.h
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
$(PROJECT_INCLUDE)/bsp/irq_supp.h: ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/irq_supp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq_supp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq_supp.h

View File

@@ -87,6 +87,9 @@ SECTIONS
_bsd__start_set_sysctl_set = .;
*(_bsd_set_sysctl_set);
_bsd__stop_set_sysctl_set = .;
_bsd__start_set_sysinit_set = .;
*(_bsd_set_sysinit_*);
_bsd__stop_set_sysinit_set = .;
bsp_section_rodata_end = .;
} > RAM

View File

@@ -54,7 +54,7 @@ static int clkirq;
} \
} while(0)
#else
#define Adjust_clkirq_for_node()
#define Adjust_clkirq_for_node() do { clkirq += LEON3_CLOCK_INDEX; } while(0)
#endif
#define Clock_driver_support_find_timer() \
@@ -67,7 +67,7 @@ static int clkirq;
if ( cnt > 0 ){ \
/* Found APB GPTIMER Timer */ \
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start; \
clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
clkirq = (LEON3_Timer_Regs->status & 0xf8) >> 3; \
\
Adjust_clkirq_for_node(); \
} \
@@ -102,10 +102,10 @@ uint32_t bsp_clock_nanoseconds_since_last_tick(void)
if ( !LEON3_Timer_Regs )
return 0;
clicks = LEON3_Timer_Regs->timer[0].value;
clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value;
if ( LEON_Is_interrupt_pending( clkirq ) ) {
clicks = LEON3_Timer_Regs->timer[0].value;
clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value;
usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
} else {
usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);

View File

@@ -46,67 +46,6 @@ extern "C" {
( (_trap) >= 0x11 && \
(_trap) <= 0x1F )
/*
* Structure for LEON memory mapped registers.
*
* Source: Section 6.1 - On-chip registers
*
* NOTE: There is only one of these structures per CPU, its base address
* is 0x80000000, and the variable LEON_REG is placed there by the
* linkcmds file.
*/
/* Leon uses dynamic register mapping using amba configuration records,
* LEON_Register_Map is obsolete
*/
/*
typedef struct {
volatile unsigned int Memory_Config_1;
volatile unsigned int Memory_Config_2;
volatile unsigned int Edac_Control;
volatile unsigned int Failed_Address;
volatile unsigned int Memory_Status;
volatile unsigned int Cache_Control;
volatile unsigned int Power_Down;
volatile unsigned int Write_Protection_1;
volatile unsigned int Write_Protection_2;
volatile unsigned int Leon_Configuration;
volatile unsigned int dummy2;
volatile unsigned int dummy3;
volatile unsigned int dummy4;
volatile unsigned int dummy5;
volatile unsigned int dummy6;
volatile unsigned int dummy7;
volatile unsigned int Timer_Counter_1;
volatile unsigned int Timer_Reload_1;
volatile unsigned int Timer_Control_1;
volatile unsigned int Watchdog;
volatile unsigned int Timer_Counter_2;
volatile unsigned int Timer_Reload_2;
volatile unsigned int Timer_Control_2;
volatile unsigned int dummy8;
volatile unsigned int Scaler_Counter;
volatile unsigned int Scaler_Reload;
volatile unsigned int dummy9;
volatile unsigned int dummy10;
volatile unsigned int UART_Channel_1;
volatile unsigned int UART_Status_1;
volatile unsigned int UART_Control_1;
volatile unsigned int UART_Scaler_1;
volatile unsigned int UART_Channel_2;
volatile unsigned int UART_Status_2;
volatile unsigned int UART_Control_2;
volatile unsigned int UART_Scaler_2;
volatile unsigned int Interrupt_Mask;
volatile unsigned int Interrupt_Pending;
volatile unsigned int Interrupt_Force;
volatile unsigned int Interrupt_Clear;
volatile unsigned int PIO_Data;
volatile unsigned int PIO_Direction;
volatile unsigned int PIO_Interrupt;
} LEON_Register_Map;
*/
typedef struct {
volatile unsigned int data;
volatile unsigned int status;
@@ -193,7 +132,6 @@ typedef struct {
#define LEON_REG_UART_STATUS_FE 0x00000040 /* RX Framing Error */
#define LEON_REG_UART_STATUS_ERR 0x00000078 /* Error Mask */
/*
* The following defines the bits in the LEON UART Status Registers.
*/
@@ -211,6 +149,7 @@ extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt
extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */
extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
/* LEON3 CPU Index of boot CPU */
extern int LEON3_Cpu_Index;
/* Macros used for manipulating bits in LEON3 GP Timer Control Register */
@@ -256,7 +195,6 @@ extern int LEON3_Cpu_Index;
(LEON3_IrqCtrl_Regs->mask[LEON3_Cpu_Index] & (1 << (_source))); \
} while (0)
#define LEON_Mask_interrupt( _source ) \
do { \
uint32_t _level; \

View File

@@ -105,7 +105,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_null_node(
* This function returns a pointer to the root node of @a the_rbtree.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_Root( the_rbtree );
@@ -117,7 +117,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root(
* This function returns a pointer to the minimum node of @a the_rbtree.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_First( the_rbtree, RBT_LEFT );
@@ -129,7 +129,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min(
* This function returns a pointer to the maximum node of @a the_rbtree.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_First( the_rbtree, RBT_RIGHT );
@@ -141,7 +141,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max(
* This function returns a pointer to the left child node of @a the_node.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left(
rtems_rbtree_node *the_node
const rtems_rbtree_node *the_node
)
{
return _RBTree_Left( the_node );
@@ -153,7 +153,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left(
* This function returns a pointer to the right child node of @a the_node.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right(
rtems_rbtree_node *the_node
const rtems_rbtree_node *the_node
)
{
return _RBTree_Right( the_node );
@@ -165,7 +165,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right(
* This function returns a pointer to the parent node of @a the_node.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_parent(
rtems_rbtree_node *the_node
const rtems_rbtree_node *the_node
)
{
return _RBTree_Parent( the_node );
@@ -192,7 +192,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_are_nodes_equal(
* false otherwise.
*/
RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_Is_empty( the_rbtree );
@@ -205,7 +205,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty(
* and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min(
rtems_rbtree_control *the_rbtree,
const rtems_rbtree_control *the_rbtree,
const rtems_rbtree_node *the_node
)
{
@@ -219,7 +219,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min(
* and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_max(
rtems_rbtree_control *the_rbtree,
const rtems_rbtree_control *the_rbtree,
const rtems_rbtree_node *the_node
)
{
@@ -247,7 +247,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_has_only_one_node(
* false otherwise.
*/
RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_root(
rtems_rbtree_control *the_rbtree,
const rtems_rbtree_control *the_rbtree,
const rtems_rbtree_node *the_node
)
{
@@ -346,7 +346,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max(
* It disables interrupts to ensure the atomicity of the peek operation.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_Peek( the_rbtree, RBT_LEFT );
@@ -361,7 +361,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min(
* It disables interrupts to ensure the atomicity of the peek operation.
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_max(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return _RBTree_Peek( the_rbtree, RBT_RIGHT );
@@ -404,7 +404,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_insert(
/** @brief Determines whether the tree is unique
*/
RTEMS_INLINE_ROUTINE rtems_rbtree_unique rtems_rbtree_is_unique(
rtems_rbtree_control *the_rbtree
const rtems_rbtree_control *the_rbtree
)
{
return( _RBTree_Is_unique(the_rbtree) );

View File

@@ -37,6 +37,7 @@ libscorecpu_a_SOURCES += nios2-isr-install-raw-handler.c
libscorecpu_a_SOURCES += nios2-isr-install-vector.c
libscorecpu_a_SOURCES += nios2-isr-is-in-progress.c
libscorecpu_a_SOURCES += nios2-isr-set-level.c
libscorecpu_a_SOURCES += nios2-mpu-add-region.c
libscorecpu_a_SOURCES += nios2-mpu-configuration.c
libscorecpu_a_SOURCES += nios2-mpu-descriptor.c
libscorecpu_a_SOURCES += nios2-mpu-disable-protected.c

View File

@@ -70,6 +70,9 @@ _Nios2_ISR_Dispatch_with_shadow_non_preemptive:
/* Load Nios II specific thread dispatch disabled */
ldw r13, %gprel(_Nios2_Thread_dispatch_disabled)(gp)
/* Read status */
rdctl r14, status
/* Fix return address */
subi ea, ea, 4
@@ -88,7 +91,7 @@ _Nios2_ISR_Dispatch_with_shadow_non_preemptive:
beq r12, zero, no_thread_dispatch
/* Is outermost interrupt? */
andhi r14, sstatus, 0x3f
andhi r14, r14, 0x3f
bne r14, zero, no_thread_dispatch
/* Is Nios II specific thread dispatch allowed? */

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2011 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/score/nios2-utility.h>
static bool _Nios2_MPU_Is_region_disabled(
const Nios2_MPU_Configuration *config,
uint32_t mpubase,
uint32_t mpuacc
)
{
bool disabled = false;
if ( config->region_uses_limit ) {
disabled = (mpubase & NIOS2_MPUBASE_BASE_MASK)
> (mpuacc & NIOS2_MPUACC_LIMIT_MASK);
} else {
disabled = (mpuacc & NIOS2_MPUACC_MASK_MASK) == 0;
}
return disabled;
}
int _Nios2_MPU_Get_disabled_region_index(
const Nios2_MPU_Configuration *config,
bool data,
int begin,
int end
)
{
int index = -1;
int count = _Nios2_MPU_Get_region_count( config, data );
if ( end < 0 || count < end ) {
end = count;
}
if ( begin >= 0 ) {
int i = 0;
for ( i = begin; i < end && index < 0; ++i ) {
uint32_t mpubase = 0;
uint32_t mpuacc = 0;
_Nios2_MPU_Get_region_registers( i, data, &mpubase, &mpuacc );
if ( _Nios2_MPU_Is_region_disabled( config, mpubase, mpuacc ) ) {
index = i;
}
}
}
return index;
}
bool _Nios2_MPU_Add_region(
const Nios2_MPU_Configuration *config,
const Nios2_MPU_Region_descriptor *desc,
bool force
)
{
bool ok = true;
int index = desc->index;
bool data = desc->data;
uint32_t mpubase = 0;
uint32_t mpuacc = 0;
if ( _Nios2_MPU_Is_valid_index( config, data, index ) ) {
if ( !force ) {
_Nios2_MPU_Get_region_registers( index, data, &mpubase, &mpuacc );
ok = _Nios2_MPU_Is_region_disabled( config, mpubase, mpuacc );
}
if ( ok ) {
ok = _Nios2_MPU_Setup_region_registers(
config,
desc,
&mpubase,
&mpuacc
);
if ( ok ) {
_Nios2_Set_ctlreg_mpubase(mpubase);
_Nios2_Set_ctlreg_mpuacc(mpuacc);
}
}
} else {
ok = false;
}
return ok;
}

View File

@@ -60,19 +60,6 @@ static bool _Nios2_Is_valid_base_and_end(
return ok;
}
static bool _Nios2_Is_valid_index(
const Nios2_MPU_Configuration *config,
bool data,
int index
)
{
int count = data ?
config->data_region_count
: config->instruction_region_count;
return 0 <= index && index < count;
}
static bool _Nios2_Is_valid_permission(
bool data,
int perm
@@ -101,7 +88,7 @@ bool _Nios2_MPU_Setup_region_registers(
&mask_or_limit
);
bool ok = is_valid_base_and_end
&& _Nios2_Is_valid_index( config, desc->data, desc->index )
&& _Nios2_MPU_Is_valid_index( config, desc->data, desc->index )
&& _Nios2_Is_valid_permission( desc->data, desc->perm )
&& !(!desc->data && desc->cacheable)
&& !(desc->read && desc->write);

View File

@@ -169,13 +169,10 @@ extern char _Nios2_ISR_Status_mask [];
*/
extern char _Nios2_ISR_Status_bits [];
/**
* @brief This global variable indicates that the Nios2 MPU is active
*
* This global variable is set to 1 when the board support package
* initializes the MPU during startup.
*/
extern uint32_t _Nios2_Mpu_active;
static inline void _Nios2_Flush_pipeline( void )
{
__asm__ volatile ("flushp");
}
static inline uint32_t _Nios2_Get_ctlreg_status( void )
{
@@ -377,6 +374,26 @@ typedef struct {
true, false, false, true \
}
static inline int _Nios2_MPU_Get_region_count(
const Nios2_MPU_Configuration *config,
bool data
)
{
return data ?
config->data_region_count
: config->instruction_region_count;
}
static inline bool _Nios2_MPU_Is_valid_index(
const Nios2_MPU_Configuration *config,
bool data,
int index
)
{
return 0 <= index
&& index < _Nios2_MPU_Get_region_count( config, data );
}
bool _Nios2_MPU_Setup_region_registers(
const Nios2_MPU_Configuration *config,
const Nios2_MPU_Region_descriptor *desc,
@@ -384,6 +401,38 @@ bool _Nios2_MPU_Setup_region_registers(
uint32_t *mpuacc
);
/**
* @brief Seaches the region table part for a disabled region.
*
* The table will be searched between indices @a begin and @a end. The @a end
* index is not part of the search range. If @a end is negative, then the
* region count will be used. Thus a @a begin of 0 and a @a end of -1 will
* specifiy the complete table.
*
* @retval -1 No disabled region is available.
* @retval other Index of disabled region.
*/
int _Nios2_MPU_Get_disabled_region_index(
const Nios2_MPU_Configuration *config,
bool data,
int begin,
int end
);
/**
* @brief Adds a region according to region descriptor @a desc.
*
* If @a force is true, then an enabled region will be overwritten.
*
* @retval true Successful operation.
* @retval false Invalid region descriptor or region already in use.
*/
bool _Nios2_MPU_Add_region(
const Nios2_MPU_Configuration *config,
const Nios2_MPU_Region_descriptor *desc,
bool force
);
static inline void _Nios2_MPU_Get_region_registers(
int index,
bool data,
@@ -397,6 +446,7 @@ static inline void _Nios2_MPU_Get_region_registers(
_Nios2_Set_ctlreg_mpubase( base );
_Nios2_Set_ctlreg_mpuacc( NIOS2_MPUACC_RD );
_Nios2_Flush_pipeline();
*mpubase = _Nios2_Get_ctlreg_mpubase() | base;
*mpuacc = _Nios2_Get_ctlreg_mpuacc();
}

View File

@@ -109,8 +109,8 @@ typedef enum {
* the order in a red-black tree.
*/
typedef int (*RBTree_Compare_function)(
RBTree_Node *node1,
RBTree_Node *node2
const RBTree_Node *node1,
const RBTree_Node *node2
);
/**
@@ -232,7 +232,7 @@ RBTree_Node *_RBTree_Get(
* @note It disables interrupts to ensure the atomicity of the get operation.
*/
RBTree_Node *_RBTree_Peek(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
RBTree_Direction dir
);

View File

@@ -38,7 +38,7 @@ RTEMS_INLINE_ROUTINE RBTree_Direction _RBTree_Opposite_direction(
RBTree_Direction the_dir
)
{
return (!the_dir);
return (RBTree_Direction) !((int) the_dir);
}
/** @brief Set off rbtree
@@ -107,7 +107,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Is_null_node(
* This function returns a pointer to the root node of @a the_rbtree.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root(
RBTree_Control *the_rbtree
const RBTree_Control *the_rbtree
)
{
return the_rbtree->root;
@@ -119,7 +119,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root(
* where @a dir specifies whether to return the minimum (0) or maximum (1).
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_First(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
RBTree_Direction dir
)
{
@@ -131,7 +131,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_First(
* This function returns a pointer to the parent node of @a the_node.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
if (!the_node->parent->parent) return NULL;
@@ -147,7 +147,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent(
* @return This method returns the left node on the rbtree.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
return the_node->child[RBT_LEFT];
@@ -162,7 +162,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left(
* @return This method returns the right node on the rbtree.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
return the_node->child[RBT_RIGHT];
@@ -179,7 +179,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right(
* @a the_rbtree and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty(
RBTree_Control *the_rbtree
const RBTree_Control *the_rbtree
)
{
return (the_rbtree->root == NULL);
@@ -193,7 +193,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty(
*
*/
RTEMS_INLINE_ROUTINE bool _RBTree_Is_first(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
const RBTree_Node *the_node,
RBTree_Direction dir
)
@@ -233,7 +233,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Has_only_one_node(
* false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _RBTree_Is_root(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
const RBTree_Node *the_node
)
{
@@ -265,7 +265,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty(
*
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Grandparent(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
if(!the_node) return NULL;
@@ -281,7 +281,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Grandparent(
* exists, and NULL if not.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Sibling(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
if(!the_node) return NULL;
@@ -300,7 +300,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Sibling(
* @a the_node if it exists, and NULL if not.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent_sibling(
RBTree_Node *the_node
const RBTree_Node *the_node
)
{
if(!the_node) return NULL;
@@ -324,6 +324,25 @@ RTEMS_INLINE_ROUTINE RBTree_Control *_RBTree_Find_header_unprotected(
return (RBTree_Control*)the_node;
}
RTEMS_INLINE_ROUTINE bool _RBTree_Is_equal( int compare_result )
{
return compare_result == 0;
}
RTEMS_INLINE_ROUTINE bool _RBTree_Is_greater(
int compare_result
)
{
return compare_result > 0;
}
RTEMS_INLINE_ROUTINE bool _RBTree_Is_lesser(
int compare_result
)
{
return compare_result < 0;
}
/** @brief Find the node with given key in the tree
*
* This function returns a pointer to the node in @a the_rbtree
@@ -343,13 +362,14 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Find_unprotected(
int compare_result;
while (iter_node) {
compare_result = the_rbtree->compare_function(the_node, iter_node);
if (compare_result == 0) {
if ( _RBTree_Is_equal( compare_result ) ) {
found = iter_node;
if ( the_rbtree->is_unique )
break;
}
RBTree_Direction dir = (compare_result == 1);
RBTree_Direction dir =
(RBTree_Direction) _RBTree_Is_greater( compare_result );
iter_node = iter_node->child[dir];
} /* while(iter_node) */
@@ -426,7 +446,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Get_unprotected(
* @retval NULL if @a the_rbtree is empty.
*/
RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Peek_unprotected(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
RBTree_Direction dir
)
{
@@ -464,7 +484,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Rotate(
/** @brief Determines whether the tree is unique
*/
RTEMS_INLINE_ROUTINE bool _RBTree_Is_unique(
RBTree_Control *the_rbtree
const RBTree_Control *the_rbtree
)
{
return( the_rbtree && the_rbtree->is_unique );

View File

@@ -97,9 +97,9 @@ RBTree_Node *_RBTree_Insert_unprotected(
/* typical binary search tree insert, descend tree to leaf and insert */
while (iter_node) {
compare_result = the_rbtree->compare_function(the_node, iter_node);
if ( the_rbtree->is_unique && !compare_result )
if ( the_rbtree->is_unique && _RBTree_Is_equal( compare_result ) )
return iter_node;
RBTree_Direction dir = (compare_result != -1);
RBTree_Direction dir = !_RBTree_Is_lesser( compare_result );
if (!iter_node->child[dir]) {
the_node->child[RBT_LEFT] = the_node->child[RBT_RIGHT] = NULL;
the_node->color = RBT_RED;

View File

@@ -36,7 +36,7 @@
*/
RBTree_Node *_RBTree_Peek(
RBTree_Control *the_rbtree,
const RBTree_Control *the_rbtree,
RBTree_Direction dir
)
{

View File

@@ -20,8 +20,8 @@
static int _Scheduler_EDF_RBTree_compare_function
(
RBTree_Node* n1,
RBTree_Node* n2
const RBTree_Node* n1,
const RBTree_Node* n2
)
{
Priority_Control value1 = _RBTree_Container_of
@@ -33,7 +33,7 @@ static int _Scheduler_EDF_RBTree_compare_function
* This function compares only numbers for the red-black tree,
* but priorities have an opposite sense.
*/
return (-1)*_Scheduler_Is_priority_higher_than(value1, value2);
return (-1)*_Scheduler_Priority_compare(value1, value2);
}
void _Scheduler_EDF_Initialize(void)

View File

@@ -28,16 +28,14 @@ typedef struct {
} test_node;
static int test_compare_function (
rtems_rbtree_node* n1,
rtems_rbtree_node* n2
const rtems_rbtree_node *n1,
const rtems_rbtree_node *n2
)
{
int key1 = rtems_rbtree_container_of( n1, test_node, Node )->key;
int key2 = rtems_rbtree_container_of( n2, test_node, Node )->key;
if (key1 > key2) return 1;
else if (key1 < key2) return -1;
else return 0;
return key1 - key2;
}
/*