Updated legacy code in i386 pc386

This commit is contained in:
Vipul Nayyar
2013-07-26 20:23:39 +05:30
committed by Sebastian Huber
parent f6efd0bf8a
commit 2bdcf4fd51
8 changed files with 165 additions and 287 deletions

View File

@@ -60,6 +60,7 @@
#include <errno.h> #include <errno.h>
#include <rtems/error.h> #include <rtems/error.h>
#include <rtems/rtems_bsdnet.h> #include <rtems/rtems_bsdnet.h>
#include <assert.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
@@ -163,11 +164,11 @@ struct ep_softc
struct ep_board *epb; struct ep_board *epb;
int unit; int unit;
rtems_irq_connect_data irqInfo; rtems_id rxDaemonTid;
rtems_id rxDaemonTid; rtems_id txDaemonTid;
rtems_id txDaemonTid; rtems_vector_number name;
int acceptBroadcast; int acceptBroadcast;
short tx_underrun; short tx_underrun;
short rx_no_first; short rx_no_first;
@@ -355,7 +356,7 @@ static __inline unsigned short inw( unsigned short io_addr )
* RETURNS: nothing. * RETURNS: nothing.
* *
**********************************************************************************/ **********************************************************************************/
void __inline outb( unsigned short io_addr, uint8_t out_data ) static __inline void outb( unsigned short io_addr, uint8_t out_data )
{ {
outport_byte( io_addr, out_data ); outport_byte( io_addr, out_data );
} }
@@ -401,46 +402,6 @@ static int get_eeprom_data( int id_port, int offset )
return( data ); return( data );
} }
/**********************************************************************************
*
* DESCRIPTION: Waits until the EEPROM of the card is ready to be accessed.
*
* RETURNS: 0 - not ready; 1 - ok
*
**********************************************************************************/
static int eeprom_rdy( struct ep_softc *sc )
{
int i;
for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++)
continue;
if (i >= MAX_EEPROMBUSY)
{
printf("ep%d: eeprom failed to come ready.\n", sc->unit);
return (0);
}
return (1);
}
/**********************************************************************************
*
* DESCRIPTION:
* get_e: gets a 16 bits word from the EEPROM.
* We must have set the window before call this routine.
*
* RETURNS: data from EEPROM
*
**********************************************************************************/
u_short get_e( struct ep_softc *sc, int offset )
{
if( !eeprom_rdy(sc) )
return (0xffff);
outw(BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset );
if( !eeprom_rdy(sc) )
return( 0xffff );
return( inw( BASE + EP_W0_EEPROM_DATA ) );
}
/********************************************************************************** /**********************************************************************************
* *
* DESCRIPTION: * DESCRIPTION:
@@ -450,9 +411,9 @@ u_short get_e( struct ep_softc *sc, int offset )
* RETURNS: nothing. * RETURNS: nothing.
* *
**********************************************************************************/ **********************************************************************************/
static rtems_isr ap_interrupt_handler( rtems_vector_number v ) static rtems_isr ap_interrupt_handler(void *arg)
{ {
struct ep_softc *sc = (struct ep_softc *)&ep_softc[ 0 ]; struct ep_softc *sc = (struct ep_softc *)arg;
/* de-activate any pending interrrupt, and sent and event to interrupt task /* de-activate any pending interrrupt, and sent and event to interrupt task
* to process all events required by this interrupt. * to process all events required by this interrupt.
@@ -461,30 +422,6 @@ static rtems_isr ap_interrupt_handler( rtems_vector_number v )
rtems_bsdnet_event_send( sc->rxDaemonTid, INTERRUPT_EVENT ); rtems_bsdnet_event_send( sc->rxDaemonTid, INTERRUPT_EVENT );
} }
/**********************************************************************************
*
* DESCRIPTION:
*
* RETURNS:
*
**********************************************************************************/
static void nopOn(const rtems_irq_connect_data* notUsed)
{
/* does nothing */
}
/**********************************************************************************
*
* DESCRIPTION:
*
* RETURNS:
*
**********************************************************************************/
static int _3c509_IsOn(const rtems_irq_connect_data* irq)
{
return BSP_irq_enabled_at_i8259s (irq->name);
}
/********************************************************************************** /**********************************************************************************
* *
* DESCRIPTION: * DESCRIPTION:
@@ -495,24 +432,22 @@ static int _3c509_IsOn(const rtems_irq_connect_data* irq)
**********************************************************************************/ **********************************************************************************/
static void _3c509_initialize_hardware (struct ep_softc *sc) static void _3c509_initialize_hardware (struct ep_softc *sc)
{ {
rtems_status_code st; rtems_status_code status;
epinit( sc ); epinit( sc );
/* /*
* Set up interrupts * Set up interrupts
*/ */
sc->irqInfo.hdl = ( rtems_irq_hdl )ap_interrupt_handler; printf ("3c509: IRQ with Kernel: %d\n", (int)sc->name );
sc->irqInfo.on = nopOn; status = rtems_interrupt_handler_install(
sc->irqInfo.off = nopOn; sc->name,
sc->irqInfo.isOn = _3c509_IsOn; "3c509",
RTEMS_INTERRUPT_UNIQUE,
printf ("3c509: IRQ with Kernel: %d\n", sc->irqInfo.name ); ap_interrupt_handler,
st = BSP_install_rtems_irq_handler( &sc->irqInfo ); sc
if( !st ) );
{ assert(status == RTEMS_SUCCESSFUL);
rtems_panic ("Can't attach WD interrupt handler for irq %d\n", sc->irqInfo.name );
}
} }
/********************************************************************************** /**********************************************************************************
@@ -746,8 +681,8 @@ int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *config )
*/ */
overrun = 0; overrun = 0;
resend = 0; resend = 0;
ep_unit = 0; ep_unit = 0;
ep_boards = 0; ep_boards = 0;
/* /*
* Find a free driver * Find a free driver
@@ -782,9 +717,9 @@ int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *config )
mtu = ETHERMTU; mtu = ETHERMTU;
if (config->irno) if (config->irno)
sc->irqInfo.name = config->irno; sc->name = config->irno;
else else
sc->irqInfo.name = 10; sc->name = 10;
if (config->port) if (config->port)
sc->ep_io_addr = config->port; sc->ep_io_addr = config->port;
@@ -1046,13 +981,13 @@ static int ep_isa_attach( struct isa_device *is )
irq = is->id_irq; irq = is->id_irq;
/* update the interrupt line number to registered with kernel */ /* update the interrupt line number to registered with kernel */
sc->irqInfo.name = irq; sc->name = irq;
GO_WINDOW( 0 ); GO_WINDOW( 0 );
SET_IRQ( BASE, irq ); SET_IRQ( BASE, irq );
printf( "3C509: I/O=0x%x, IRQ=%d, CONNECTOR=%s, ", printf( "3C509: I/O=0x%x, IRQ=%d, CONNECTOR=%s, ",
sc->ep_io_addr, sc->irqInfo.name,ep_conn_type[ sc->ep_connector ] ); sc->ep_io_addr, (int)sc->name,ep_conn_type[ sc->ep_connector ] );
ep_attach( sc ); ep_attach( sc );
return 1; return 1;

View File

@@ -27,6 +27,7 @@
#include <bsp/irq.h> #include <bsp/irq.h>
#include <bspopts.h> #include <bspopts.h>
#include <libcpu/cpuModel.h> #include <libcpu/cpuModel.h>
#include <assert.h>
#define CLOCK_VECTOR 0 #define CLOCK_VECTOR 0
@@ -36,15 +37,12 @@ uint32_t pc386_clock_click_count;
/* forward declaration */ /* forward declaration */
void Clock_isr(void *param); void Clock_isr(void *param);
void Clock_driver_support_at_tick_tsc(void); static void Clock_driver_support_at_tick_empty(void);
void Clock_driver_support_at_tick_empty(void); static void clockOff(void);
uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void); static void Clock_driver_support_at_tick_tsc(void);
uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void); static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void);
void Clock_isr_handler(rtems_irq_hdl_param param); static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void);
int clockIsOn(const rtems_irq_connect_data* unused); static void Clock_isr_handler(void *param);
void clockOff(const rtems_irq_connect_data* unused);
void Clock_driver_install_handler(void);
void Clock_driver_support_initialize_hardware(void);
/* /*
* Roughly the number of cycles per tick and per nanosecond. Note that these * Roughly the number of cycles per tick and per nanosecond. Note that these
@@ -83,7 +81,7 @@ uint32_t (*Clock_driver_nanoseconds_since_last_tick)(void) = NULL;
/* /*
* What do we do at each clock tick? * What do we do at each clock tick?
*/ */
void Clock_driver_support_at_tick_tsc(void) static void Clock_driver_support_at_tick_tsc(void)
{ {
#ifdef CLOCK_DRIVER_ISRS_PER_TICK #ifdef CLOCK_DRIVER_ISRS_PER_TICK
/* /*
@@ -99,7 +97,7 @@ void Clock_driver_support_at_tick_tsc(void)
#endif #endif
} }
void Clock_driver_support_at_tick_empty(void) static void Clock_driver_support_at_tick_empty(void)
{ {
} }
@@ -113,7 +111,7 @@ extern volatile uint32_t Clock_driver_isrs;
/* /*
* Get nanoseconds using Pentium-compatible TSC register * Get nanoseconds using Pentium-compatible TSC register
*/ */
uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void) static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
{ {
uint64_t diff_nsec; uint64_t diff_nsec;
@@ -140,7 +138,7 @@ uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
/* /*
* Get nanoseconds using 8254 timer chip * Get nanoseconds using 8254 timer chip
*/ */
uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void) static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void)
{ {
uint32_t usecs, clicks, isrs; uint32_t usecs, clicks, isrs;
uint32_t usecs1, usecs2; uint32_t usecs1, usecs2;
@@ -232,9 +230,7 @@ static void calibrate_tsc(void)
pc586_tsc_per_tick /= rtems_clock_get_ticks_per_second(); pc586_tsc_per_tick /= rtems_clock_get_ticks_per_second();
} }
static void clockOn( static void clockOn(void)
const rtems_irq_connect_data* unused
)
{ {
pc386_isrs_per_tick = 1; pc386_isrs_per_tick = 1;
pc386_microseconds_per_isr = rtems_configuration_get_microseconds_per_tick(); pc386_microseconds_per_isr = rtems_configuration_get_microseconds_per_tick();
@@ -267,7 +263,7 @@ static void clockOn(
calibrate_tsc(); calibrate_tsc();
} }
void clockOff(const rtems_irq_connect_data* unused) static void clockOff(void)
{ {
/* reset timer mode to standard (BIOS) value */ /* reset timer mode to standard (BIOS) value */
outport_byte(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN); outport_byte(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
@@ -275,35 +271,27 @@ void clockOff(const rtems_irq_connect_data* unused)
outport_byte(TIMER_CNTR0, 0); outport_byte(TIMER_CNTR0, 0);
} /* Clock_exit */ } /* Clock_exit */
int clockIsOn(const rtems_irq_connect_data* unused)
{
return ((i8259s_cache & 0x1) == 0);
}
bool Clock_isr_enabled = false; bool Clock_isr_enabled = false;
void Clock_isr_handler( static void Clock_isr_handler(void *param)
rtems_irq_hdl_param param
)
{ {
if ( Clock_isr_enabled ) if ( Clock_isr_enabled )
Clock_isr( param ); Clock_isr( param );
} }
static rtems_irq_connect_data clockIrqData = {
BSP_PERIODIC_TIMER,
Clock_isr_handler,
0,
clockOn,
clockOff,
clockIsOn
};
void Clock_driver_install_handler(void) void Clock_driver_install_handler(void)
{ {
if (!BSP_install_rtems_irq_handler (&clockIrqData)) { rtems_status_code status;
printk("Unable to install system clock ISR handler\n");
rtems_fatal_error_occurred(1); status = rtems_interrupt_handler_install(
} BSP_PERIODIC_TIMER,
"ckinit",
RTEMS_INTERRUPT_UNIQUE,
Clock_isr_handler,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
clockOn();
} }
void Clock_driver_support_initialize_hardware(void) void Clock_driver_support_initialize_hardware(void)
@@ -349,7 +337,14 @@ void Clock_driver_support_initialize_hardware(void)
#define Clock_driver_support_shutdown_hardware() \ #define Clock_driver_support_shutdown_hardware() \
do { \ do { \
BSP_remove_rtems_irq_handler (&clockIrqData); \ rtems_status_code status; \
clockOff(); \
status = rtems_interrupt_handler_remove( \
BSP_PERIODIC_TIMER, \
Clock_isr_handler, \
NULL \
); \
assert(status == RTEMS_SUCCESSFUL); \
} while (0) } while (0)
#include "../../../shared/clockdrv_shell.h" #include "../../../shared/clockdrv_shell.h"

View File

@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <assert.h>
#include <bsp.h> #include <bsp.h>
#include <bsp/irq.h> #include <bsp/irq.h>
@@ -29,6 +30,7 @@
#define INITIALIZE_MOUSE #define INITIALIZE_MOUSE
/* Some configuration switches are present in the include file... */ /* Some configuration switches are present in the include file... */
#include "ps2_mouse.h" #include "ps2_mouse.h"
#include "ps2_drv.h"
static void kbd_write_command_w(int data); static void kbd_write_command_w(int data);
#if 0 #if 0
@@ -36,6 +38,7 @@ static void kbd_write_output_w(int data);
#endif #endif
static unsigned char handle_kbd_event(void); static unsigned char handle_kbd_event(void);
static void ps2_set_driver_handler(int port, mouse_parser_enqueue_handler handler);
/* used only by send_data - set by keyboard_interrupt */ /* used only by send_data - set by keyboard_interrupt */
static volatile unsigned char reply_expected = 0; static volatile unsigned char reply_expected = 0;
@@ -56,14 +59,14 @@ static unsigned char mouse_reply_expected = 0;
#define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
#define MAX_RETRIES 60 /* some aux operations take long time*/ #define MAX_RETRIES 60 /* some aux operations take long time*/
static void ps2_mouse_interrupt(rtems_irq_hdl_param); static void ps2_mouse_interrupt(void *);
static mouse_parser_enqueue_handler driver_input_handler_ps2 = NULL; static mouse_parser_enqueue_handler driver_input_handler_ps2 = NULL;
/* /*
* This routine sets the handler to handle the characters received * This routine sets the handler to handle the characters received
* from the serial port. * from the serial port.
*/ */
void ps2_set_driver_handler( static void ps2_set_driver_handler(
int port, int port,
mouse_parser_enqueue_handler handler mouse_parser_enqueue_handler handler
) )
@@ -78,30 +81,6 @@ static void mdelay( unsigned long t )
static void* termios_ttyp_paux = NULL; static void* termios_ttyp_paux = NULL;
static void
isr_on(const rtems_irq_connect_data *unused)
{
return;
}
static void
isr_off(const rtems_irq_connect_data *unused)
{
return;
}
static int isr_is_on(const rtems_irq_connect_data *irq)
{
return BSP_irq_enabled_at_i8259s( irq->name );
}
static rtems_irq_connect_data ps2_isr_data = { AUX_IRQ,
ps2_mouse_interrupt,
0,
isr_on,
isr_off,
isr_is_on };
/* /*
* Wait for keyboard controller input buffer to drain. * Wait for keyboard controller input buffer to drain.
* *
@@ -223,7 +202,7 @@ static unsigned char handle_kbd_event(void)
return status; return status;
} }
static void ps2_mouse_interrupt(rtems_irq_hdl_param ignored) static void ps2_mouse_interrupt(void * unused)
{ {
handle_kbd_event(); handle_kbd_event();
} }
@@ -323,11 +302,17 @@ static int queue_empty(void)
static int release_aux(void) static int release_aux(void)
{ {
rtems_status_code status;
if (--aux_count) if (--aux_count)
return 0; return 0;
kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */
kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE); kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE);
BSP_remove_rtems_irq_handler( &ps2_isr_data ); status = rtems_interrupt_handler_remove(
AUX_IRQ,
ps2_mouse_interrupt,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
return 0; return 0;
} }
@@ -338,18 +323,21 @@ static int release_aux(void)
static int open_aux(void) static int open_aux(void)
{ {
int status; rtems_status_code status;
if (aux_count++) { if (aux_count++) {
return 0; return 0;
} }
queue->head = queue->tail = 0; /* Flush input queue */ queue->head = queue->tail = 0; /* Flush input queue */
status = BSP_install_rtems_irq_handler( &ps2_isr_data ); status = rtems_interrupt_handler_install(
if( !status ) { AUX_IRQ,
printk("Error installing ps2-mouse interrupt handler!\n" ); "ps2_mouse",
rtems_fatal_error_occurred( status ); RTEMS_INTERRUPT_UNIQUE,
} ps2_mouse_interrupt,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on
controller. */ controller. */
@@ -429,7 +417,7 @@ static int psaux_init( void )
/* /*
* paux device driver INITIALIZE entry point. * paux device driver INITIALIZE entry point.
*/ */
rtems_device_driver paux_initialize( rtems_device_driver paux_initialize(
rtems_device_major_number major, rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg)

View File

@@ -1,5 +1,5 @@
/* /*
* This file contains the termios TTY driver for the i386 * This file contains the termios TTY driver for the i386
* vga. * vga.
* *
* COPYRIGHT (c) 1989-2011. * COPYRIGHT (c) 1989-2011.
@@ -20,23 +20,11 @@
#include <bsp/irq.h> #include <bsp/irq.h>
#include <bsp.h> #include <bsp.h>
#include <crt.h> #include <crt.h>
#include <assert.h>
#include "keyboard.h"
#define VGACONS_STATIC static #define VGACONS_STATIC static
static int isr_is_on(const rtems_irq_connect_data *irq)
{
return BSP_irq_enabled_at_i8259s(irq->name);
}
static rtems_irq_connect_data keyboard_isr_data = {
BSP_KEYBOARD,
keyboard_interrupt,
0,
NULL,
NULL,
isr_is_on
};
/* /*
* vgacons_init * vgacons_init
* *
@@ -44,7 +32,7 @@ static rtems_irq_connect_data keyboard_isr_data = {
*/ */
VGACONS_STATIC void vgacons_init(int minor) VGACONS_STATIC void vgacons_init(int minor)
{ {
/* /*
* Note: We do not initialize the KBD interface here since * Note: We do not initialize the KBD interface here since
* it was initialized regardless of whether the * it was initialized regardless of whether the
* vga is available or not. Therefore it is initialized * vga is available or not. Therefore it is initialized
@@ -160,7 +148,7 @@ bool vgacons_probe(
int minor int minor
) )
{ {
int status; rtems_status_code status;
static bool firstTime = true; static bool firstTime = true;
if ((*(unsigned char*) NB_MAX_ROW_ADDR == 0) && if ((*(unsigned char*) NB_MAX_ROW_ADDR == 0) &&
@@ -175,11 +163,14 @@ bool vgacons_probe(
* can be COM1 and you can still use the mouse/VGA for graphics. * can be COM1 and you can still use the mouse/VGA for graphics.
*/ */
if ( firstTime ) { if ( firstTime ) {
status = BSP_install_rtems_irq_handler(&keyboard_isr_data); status = rtems_interrupt_handler_install(
if (!status) { BSP_KEYBOARD,
printk("Error installing keyboard interrupt handler!\n"); "vgacons",
rtems_fatal_error_occurred(status); RTEMS_INTERRUPT_UNIQUE,
} keyboard_interrupt,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
} }
firstTime = false; firstTime = false;

View File

@@ -80,6 +80,10 @@ extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
#define BSP_DEC21140_NETWORK_DRIVER_NAME "dc1" #define BSP_DEC21140_NETWORK_DRIVER_NAME "dc1"
#define BSP_DEC21140_NETWORK_DRIVER_ATTACH rtems_dec21140_driver_attach #define BSP_DEC21140_NETWORK_DRIVER_ATTACH rtems_dec21140_driver_attach
extern int rtems_3c509_driver_attach(struct rtems_bsdnet_ifconfig *config);
#define BSP_3C509_NETWORK_DRIVER_NAME "3c1"
#define BSP_3C509_NETWORK_DRIVER_ATTACH rtems_3c509_driver_attach
#ifndef RTEMS_BSP_NETWORK_DRIVER_NAME #ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
#define RTEMS_BSP_NETWORK_DRIVER_NAME BSP_DEC21140_NETWORK_DRIVER_NAME #define RTEMS_BSP_NETWORK_DRIVER_NAME BSP_DEC21140_NETWORK_DRIVER_NAME
#endif #endif
@@ -134,7 +138,7 @@ extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
/*-------------------------------------------------------------------------+ /*-------------------------------------------------------------------------+
| Console Defines | Console Defines
| WARNING: These Values MUST match the order in | WARNING: These Values MUST match the order in
| Console_Configuration_Ports | Console_Configuration_Ports
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
#define BSP_CONSOLE_VGA 0 #define BSP_CONSOLE_VGA 0
@@ -182,6 +186,10 @@ char _IBMPC_inch_sleep (void); /* from 'inch.c' */
void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c' */ void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c' */
void Clock_driver_install_handler(void); /* from 'ckinit.c' */
void Clock_driver_support_initialize_hardware(void); /* from 'ckinit.c' */
size_t read_aux(char * buffer, size_t count); /* from 'ps2_mouse.c' */
/* Definitions for BSPConsolePort */ /* Definitions for BSPConsolePort */
#define BSP_CONSOLE_PORT_CONSOLE (-1) #define BSP_CONSOLE_PORT_CONSOLE (-1)
#define BSP_CONSOLE_PORT_COM1 (BSP_UART_COM1) #define BSP_CONSOLE_PORT_COM1 (BSP_UART_COM1)

View File

@@ -18,6 +18,7 @@
#include <errno.h> #include <errno.h>
#include <rtems/error.h> #include <rtems/error.h>
#include <rtems/rtems_bsdnet.h> #include <rtems/rtems_bsdnet.h>
#include <assert.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
@@ -73,7 +74,6 @@
*/ */
struct wd_softc { struct wd_softc {
struct arpcom arpcom; struct arpcom arpcom;
rtems_irq_connect_data irqInfo;
struct mbuf **rxMbuf; struct mbuf **rxMbuf;
struct mbuf **txMbuf; struct mbuf **txMbuf;
int acceptBroadcast; int acceptBroadcast;
@@ -84,6 +84,7 @@ struct wd_softc {
int txBdActiveCount; int txBdActiveCount;
rtems_id rxDaemonTid; rtems_id rxDaemonTid;
rtems_id txDaemonTid; rtems_id txDaemonTid;
rtems_vector_number name;
unsigned int port; unsigned int port;
unsigned char *base; unsigned char *base;
@@ -127,7 +128,7 @@ static struct wd_softc wd_softc[NWDDRIVER];
* WD interrupt handler * WD interrupt handler
*/ */
static void static void
wd8003Enet_interrupt_handler (void *unused) wd8003Enet_interrupt_handler (void * unused)
{ {
unsigned int tport; unsigned int tport;
unsigned char status, status2; unsigned char status, status2;
@@ -169,19 +170,6 @@ wd8003Enet_interrupt_handler (void *unused)
} }
static void nopOn(const rtems_irq_connect_data* notUsed)
{
/*
* code should be moved from wd8003Enet_initialize_hardware
* to this location
*/
}
static int wdIsOn(const rtems_irq_connect_data* irq)
{
return BSP_irq_enabled_at_i8259s (irq->name);
}
/* /*
* Initialize the ethernet hardware * Initialize the ethernet hardware
*/ */
@@ -191,7 +179,7 @@ wd8003Enet_initialize_hardware (struct wd_softc *sc)
int i1, ultra; int i1, ultra;
char cc1, cc2; char cc1, cc2;
unsigned char temp; unsigned char temp;
rtems_status_code st; rtems_status_code status;
unsigned int tport; unsigned int tport;
unsigned char *hwaddr; unsigned char *hwaddr;
@@ -257,15 +245,15 @@ wd8003Enet_initialize_hardware (struct wd_softc *sc)
/* /*
* Set up interrupts * Set up interrupts
*/ */
sc->irqInfo.hdl = wd8003Enet_interrupt_handler;
sc->irqInfo.on = nopOn;
sc->irqInfo.off = nopOn;
sc->irqInfo.isOn = wdIsOn;
st = BSP_install_rtems_irq_handler (&sc->irqInfo); status = rtems_interrupt_handler_install(
if (!st) sc->name,
rtems_panic ("Can't attach WD interrupt handler for irq %d\n", "wd8003",
sc->irqInfo.name); RTEMS_INTERRUPT_UNIQUE,
wd8003Enet_interrupt_handler,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
} }
static void static void
@@ -397,7 +385,7 @@ sendpacket (struct ifnet *ifp, struct mbuf *m)
/* /*
* Driver transmit daemon * Driver transmit daemon
*/ */
void static void
wd_txDaemon (void *arg) wd_txDaemon (void *arg)
{ {
struct wd_softc *sc = (struct wd_softc *)arg; struct wd_softc *sc = (struct wd_softc *)arg;
@@ -607,9 +595,9 @@ rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
mtu = ETHERMTU; mtu = ETHERMTU;
if (config->irno) if (config->irno)
sc->irqInfo.name = config->irno; sc->name = config->irno;
else else
sc->irqInfo.name = 5; sc->name = 5;
if (config->port) if (config->port)
sc->port = config->port; sc->port = config->port;

View File

@@ -27,62 +27,18 @@
#include <termios.h> #include <termios.h>
#include <uart.h> #include <uart.h>
#include <libcpu/cpuModel.h> #include <libcpu/cpuModel.h>
#include "tty_drv.h"
int BSP_poll_read(int); int BSP_poll_read(int);
/* Internal routines */ /* Internal routines */
static int tty1_conSetAttr( int minor, const struct termios *t); static int tty1_conSetAttr( int minor, const struct termios *t);
static int tty2_conSetAttr( int minor, const struct termios *t); static int tty2_conSetAttr( int minor, const struct termios *t);
static void isr_on(const rtems_irq_connect_data *);
static void isr_off(const rtems_irq_connect_data *);
static int isr_is_on(const rtems_irq_connect_data *);
extern BSP_polling_getchar_function_type BSP_poll_char; extern BSP_polling_getchar_function_type BSP_poll_char;
extern int BSPConsolePort; extern int BSPConsolePort;
extern void rtems_set_waiting_id_comx( int port, rtems_id id, rtems_event_set event ); extern void rtems_set_waiting_id_comx( int port, rtems_id id, rtems_event_set event );
/*
* Interrupt structure for tty1
*/
static rtems_irq_connect_data tty1_isr_data =
{
BSP_UART_COM1_IRQ,
BSP_uart_termios_isr_com1,
0,
isr_on,
isr_off,
isr_is_on};
/*
* Interrupt structure for tty2
*/
static rtems_irq_connect_data tty2_isr_data =
{
BSP_UART_COM2_IRQ,
BSP_uart_termios_isr_com2,
0,
isr_on,
isr_off,
isr_is_on};
static void
isr_on(const rtems_irq_connect_data *unused)
{
return;
}
static void
isr_off(const rtems_irq_connect_data *unused)
{
return;
}
static int
isr_is_on(const rtems_irq_connect_data *irq)
{
return BSP_irq_enabled_at_i8259s(irq->name);
}
/* /*
* TTYS1 - device driver INITIALIZE entry point. * TTYS1 - device driver INITIALIZE entry point.
*/ */
@@ -111,12 +67,14 @@ tty1_initialize(rtems_device_major_number major,
*/ */
/* 9600-8-N-1, without hardware flow control */ /* 9600-8-N-1, without hardware flow control */
BSP_uart_init( BSP_UART_COM1, 9600, CHR_8_BITS, 0, 0, 0 ); BSP_uart_init( BSP_UART_COM1, 9600, CHR_8_BITS, 0, 0, 0 );
status = BSP_install_rtems_irq_handler( &tty1_isr_data ); status = rtems_interrupt_handler_install(
if( !status ) BSP_UART_COM1_IRQ,
{ "tty_drv",
printk("Error installing ttyS1 interrupt handler!\n"); RTEMS_INTERRUPT_UNIQUE,
rtems_fatal_error_occurred(status); BSP_uart_termios_isr_com1,
} NULL
);
assert(status == RTEMS_SUCCESSFUL);
/* /*
* Register the device * Register the device
*/ */
@@ -132,7 +90,14 @@ tty1_initialize(rtems_device_major_number major,
static int tty1_last_close(int major, int minor, void *arg) static int tty1_last_close(int major, int minor, void *arg)
{ {
BSP_remove_rtems_irq_handler( &tty1_isr_data ); rtems_status_code status;
status = rtems_interrupt_handler_remove(
BSP_UART_COM1_IRQ,
BSP_uart_termios_isr_com1,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
return 0; return 0;
} }
@@ -339,12 +304,15 @@ tty2_initialize(rtems_device_major_number major,
*/ */
/* 9600-8-N-1, without hardware flow control */ /* 9600-8-N-1, without hardware flow control */
BSP_uart_init( BSP_UART_COM2, 9600, CHR_8_BITS, 0, 0, 0); BSP_uart_init( BSP_UART_COM2, 9600, CHR_8_BITS, 0, 0, 0);
status = BSP_install_rtems_irq_handler( &tty2_isr_data ); status = rtems_interrupt_handler_install(
if( !status ) BSP_UART_COM2_IRQ,
{ "tty_drv",
printk("Error installing serial console interrupt handler!\n"); RTEMS_INTERRUPT_UNIQUE,
rtems_fatal_error_occurred(status); BSP_uart_termios_isr_com2,
} NULL
);
assert(status == RTEMS_SUCCESSFUL);
/* /*
* Register the device * Register the device
*/ */
@@ -360,7 +328,14 @@ tty2_initialize(rtems_device_major_number major,
static int tty2_last_close(int major, int minor, void *arg) static int tty2_last_close(int major, int minor, void *arg)
{ {
BSP_remove_rtems_irq_handler( &tty2_isr_data ); rtems_status_code status;
status = rtems_interrupt_handler_remove(
BSP_UART_COM2_IRQ,
BSP_uart_termios_isr_com2,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
return 0; return 0;
} }

View File

@@ -79,6 +79,7 @@
#include <rtems/bspsmp.h> #include <rtems/bspsmp.h>
#include <rtems/bspIo.h> #include <rtems/bspIo.h>
#include <libcpu/cpu.h> #include <libcpu/cpu.h>
#include <assert.h>
extern void _pc386_delay(void); extern void _pc386_delay(void);
@@ -120,14 +121,14 @@ static void UDELAY(int x)
while ( _i-- ) while ( _i-- )
_pc386_delay(); _pc386_delay();
} }
#define READ_MSR_LO(_x) \ #define READ_MSR_LO(_x) \
(unsigned int)(read_msr(_x) & 0xffffffff) (unsigned int)(read_msr(_x) & 0xffffffff)
static inline unsigned long long read_msr(unsigned int msr) static inline unsigned long long read_msr(unsigned int msr)
{ {
unsigned long long value; unsigned long long value;
asm volatile("rdmsr" : "=A" (value) : "c" (msr)); asm volatile("rdmsr" : "=A" (value) : "c" (msr));
return value; return value;
} }
@@ -385,7 +386,7 @@ imps_read_config_table(unsigned start, int count)
case IMPS_BCT_PROCESSOR: case IMPS_BCT_PROCESSOR:
if ( imps_num_cpus < rtems_configuration_get_maximum_processors() ) { if ( imps_num_cpus < rtems_configuration_get_maximum_processors() ) {
add_processor((imps_processor *)start); add_processor((imps_processor *)start);
} else } else
imps_num_cpus++; imps_num_cpus++;
start += 12; /* 20 total */ start += 12; /* 20 total */
break; break;
@@ -751,22 +752,19 @@ rtems_isr ap_ipi_isr(
#include <rtems/irq.h> #include <rtems/irq.h>
static rtems_irq_connect_data apIPIIrqData = {
16,
(void *)ap_ipi_isr,
0,
NULL, /* On */
NULL, /* Off */
NULL, /* IsOn */
};
extern void bsp_reset(void); extern void bsp_reset(void);
void ipi_install_irq(void) void ipi_install_irq(void)
{ {
if (!BSP_install_rtems_irq_handler (&apIPIIrqData)) { rtems_status_code status;
printk("Unable to initialize IPI\n");
bsp_reset(); status = rtems_interrupt_handler_install(
} 16,
"smp-imps",
RTEMS_INTERRUPT_UNIQUE,
ap_ipi_isr,
NULL
);
assert(status == RTEMS_SUCCESSFUL);
} }
#ifdef __SSE__ #ifdef __SSE__