diff options
-rw-r--r-- | c/src/ChangeLog | 5 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/ChangeLog | 9 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen5200/Makefile.am | 2 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c | 12 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c | 142 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h | 260 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen5200/mscan/mscan_int.h | 271 | ||||
-rw-r--r-- | c/src/libchip/ide/ata.c | 3 | ||||
-rw-r--r-- | cpukit/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/libblock/Makefile.am | 3 | ||||
-rw-r--r-- | cpukit/libblock/include/rtems/bdbuf.h | 44 | ||||
-rw-r--r-- | cpukit/libblock/src/bdbuf.c | 100 | ||||
-rw-r--r-- | cpukit/libblock/src/show_bdbuf.c | 904 | ||||
-rw-r--r-- | testsuites/samples/ChangeLog | 4 | ||||
-rw-r--r-- | testsuites/samples/fileio/init.c | 8 |
15 files changed, 1379 insertions, 395 deletions
diff --git a/c/src/ChangeLog b/c/src/ChangeLog index 33c0dad2a4..91d2c838fb 100644 --- a/c/src/ChangeLog +++ b/c/src/ChangeLog @@ -1,3 +1,8 @@ +2007-01-20 Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> + + * libchip/ide/ata.c: in ata_request_done: moved call to free() + from preemption disabled region + 2007-01-16 Till Straumann <strauman@slac.stanford.edu> * libchip/i2c/i2c-2b-eeprom.c, libchip/i2c/i2c-2b-eeprom.h, diff --git a/c/src/lib/libbsp/powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/ChangeLog index 27ac74ad40..760b6fe5cb 100644 --- a/c/src/lib/libbsp/powerpc/ChangeLog +++ b/c/src/lib/libbsp/powerpc/ChangeLog @@ -1,3 +1,12 @@ +2007-01-20 Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> + + * gen5200/mscan/mscan.c, + * gen5200/mscan/mscan.h, + * gen5200/mscan/mscan_int.h: + split mscan.h into two headers, corrected CAN filtering + code to + support remote requests + 2007-01-19 Till Straumann <strauman@slac.stanford.edu> * mvme5500/Makefile.am, mvme5500/preinstall.am, diff --git a/c/src/lib/libbsp/powerpc/gen5200/Makefile.am b/c/src/lib/libbsp/powerpc/gen5200/Makefile.am index e636709412..b4ab7d59d1 100644 --- a/c/src/lib/libbsp/powerpc/gen5200/Makefile.am +++ b/c/src/lib/libbsp/powerpc/gen5200/Makefile.am @@ -84,7 +84,7 @@ irq_rel_CPPFLAGS = $(AM_CPPFLAGS) irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) noinst_PROGRAMS += mscan.rel -mscan_rel_SOURCES = mscan/mscan.c mscan/mscan.h +mscan_rel_SOURCES = mscan/mscan.c mscan/mscan.h mscan/mscan_int.h mscan_rel_CPPFLAGS = $(AM_CPPFLAGS) mscan_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c b/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c index 8f338f9b82..19238119ad 100644 --- a/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c +++ b/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c @@ -91,6 +91,8 @@ #define MIN(a,b) (((a)<(b))?(a):(b)) #endif #define IDE_DMA_TEST FALSE + +#ifdef BRS5L #define IDE_USE_INT TRUE #define IDE_READ_USE_DMA TRUE #define IDE_USE_READ_PIO_OPT FALSE @@ -98,6 +100,16 @@ #define IDE_USE_WRITE_PIO_OPT TRUE /* #define IDE_USE_DMA (IDE_READ_USE_DMA||IDE_WRITE_USE_DMA) */ #define IDE_USE_DMA TRUE +#else +#define IDE_USE_INT TRUE +#define IDE_READ_USE_DMA FALSE +#define IDE_USE_READ_PIO_OPT FALSE +#define IDE_WRITE_USE_DMA FALSE +#define IDE_USE_WRITE_PIO_OPT FALSE +/* #define IDE_USE_DMA (IDE_READ_USE_DMA||IDE_WRITE_USE_DMA) */ +#define IDE_USE_DMA FALSE +#endif + #define IDE_USE_STATISTICS TRUE #if IDE_USE_DMA diff --git a/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c index f92c78e13a..be5fcd436e 100644 --- a/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c +++ b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c @@ -26,12 +26,10 @@ #include "../include/bsp.h" #include "../irq/irq.h" #include "../include/mpc5200.h" -#include "mscan.h" +#include "../mscan/mscan_int.h" /* #define MSCAN_LOOPBACK */ -volatile uint32_t tx_int_wr_count = 0; - struct mpc5200_rx_cntrl mpc5200_mscan_rx_cntrl[MPC5200_CAN_NO]; static struct mscan_channel_info chan_info[MPC5200_CAN_NO]; @@ -176,46 +174,42 @@ static void mpc5200_mscan_interrupt_handler(rtems_irq_hdl_param handle) mscan->txidr2 = 0; mscan->txidr3 = 0; - /* insert dlc into mscan register */ - mscan->txdlr = (uint8_t)((tx_mess_ptr->mess_len) & 0x000F); } - /* select one free tx buffer if TOUCAN not registered) */ - if(((mscan_hdl->toucan_callback) == NULL) || (((mscan_hdl->toucan_callback) != NULL) && ((tx_mess_ptr->toucan_tx_id) == idx))) + /* fill in tx data if TOUCAN is activ an TOUCAN index have a match with the tx buffer or TOUCAN is disabled */ + if(((mscan_hdl->toucan_callback) == NULL) || (((mscan_hdl->toucan_callback) != NULL) && ((tx_mess_ptr->toucan_tx_idx) == idx))) { - /* set tx id */ - mscan->txidr0 = SET_IDR0(tx_mess_ptr->mess_id); - mscan->txidr1 = SET_IDR1(tx_mess_ptr->mess_id); - mscan->txidr2 = 0; - mscan->txidr3 = 0; - /* insert dlc into mscan register */ mscan->txdlr = (uint8_t)((tx_mess_ptr->mess_len) & 0x000F); - /* copy tx data to MSCAN registers */ - switch(mscan->txdlr) + /* skip data copy in case of RTR */ + if(!(MSCAN_MESS_ID_HAS_RTR(tx_mess_ptr->mess_id))) { - case 8: - mscan->txdsr7 = tx_mess_ptr->mess_data[7]; - case 7: - mscan->txdsr6 = tx_mess_ptr->mess_data[6]; - case 6: - mscan->txdsr5 = tx_mess_ptr->mess_data[5]; - case 5: - mscan->txdsr4 = tx_mess_ptr->mess_data[4]; - case 4: - mscan->txdsr3 = tx_mess_ptr->mess_data[3]; - case 3: - mscan->txdsr2 = tx_mess_ptr->mess_data[2]; - case 2: - mscan->txdsr1 = tx_mess_ptr->mess_data[1]; - case 1: - mscan->txdsr0 = tx_mess_ptr->mess_data[0]; - break; - default: - break; - } + /* copy tx data to MSCAN registers */ + switch(mscan->txdlr) + { + case 8: + mscan->txdsr7 = tx_mess_ptr->mess_data[7]; + case 7: + mscan->txdsr6 = tx_mess_ptr->mess_data[6]; + case 6: + mscan->txdsr5 = tx_mess_ptr->mess_data[5]; + case 5: + mscan->txdsr4 = tx_mess_ptr->mess_data[4]; + case 4: + mscan->txdsr3 = tx_mess_ptr->mess_data[3]; + case 3: + mscan->txdsr2 = tx_mess_ptr->mess_data[2]; + case 2: + mscan->txdsr1 = tx_mess_ptr->mess_data[1]; + case 1: + mscan->txdsr0 = tx_mess_ptr->mess_data[0]; + break; + default: + break; + } + } /* enable message buffer specific interrupt */ mscan->tier |= mscan->bsel; @@ -226,8 +220,6 @@ static void mpc5200_mscan_interrupt_handler(rtems_irq_hdl_param handle) /* release counting semaphore of tx ring buffer */ rtems_semaphore_release((rtems_id)(chan->tx_rb_sid)); - tx_int_wr_count++; - } else { @@ -301,30 +293,34 @@ static void mpc5200_mscan_interrupt_handler(rtems_irq_hdl_param handle) /* get time stamp */ rx_mess_ptr->mess_time_stamp = ((mscan->rxtimh << 8) | (mscan->rxtiml)); - /* get the data */ - switch(rx_mess_ptr->mess_len) - { + /* skip data copy in case of RTR */ + if(!(MSCAN_MESS_ID_HAS_RTR(rx_mess_ptr->mess_id))) - case 8: - rx_mess_ptr->mess_data[7] = mscan->rxdsr7; - case 7: - rx_mess_ptr->mess_data[6] = mscan->rxdsr6; - case 6: - rx_mess_ptr->mess_data[5] = mscan->rxdsr5; - case 5: - rx_mess_ptr->mess_data[4] = mscan->rxdsr4; - case 4: - rx_mess_ptr->mess_data[3] = mscan->rxdsr3; - case 3: - rx_mess_ptr->mess_data[2] = mscan->rxdsr2; - case 2: - rx_mess_ptr->mess_data[1] = mscan->rxdsr1; - case 1: - rx_mess_ptr->mess_data[0] = mscan->rxdsr0; - case 0: - default: - break; + { + /* get the data */ + switch(rx_mess_ptr->mess_len) + { + case 8: + rx_mess_ptr->mess_data[7] = mscan->rxdsr7; + case 7: + rx_mess_ptr->mess_data[6] = mscan->rxdsr6; + case 6: + rx_mess_ptr->mess_data[5] = mscan->rxdsr5; + case 5: + rx_mess_ptr->mess_data[4] = mscan->rxdsr4; + case 4: + rx_mess_ptr->mess_data[3] = mscan->rxdsr3; + case 3: + rx_mess_ptr->mess_data[2] = mscan->rxdsr2; + case 2: + rx_mess_ptr->mess_data[1] = mscan->rxdsr1; + case 1: + rx_mess_ptr->mess_data[0] = mscan->rxdsr0; + case 0: + default: + break; + } } if(mscan_hdl->toucan_callback == NULL) @@ -871,15 +867,15 @@ void mpc5200_mscan_perform_init_mode_settings(volatile struct mpc5200_mscan *msc mscan->idac &= ~(IDAC_IDAM1); mscan->idac |= (IDAC_IDAM0); - /* initialize rx filter masks (16 bit) */ - mscan->idmr0 = SET_IDMR0(0x07FF); - mscan->idmr1 = SET_IDMR1(0x07FF); - mscan->idmr2 = SET_IDMR2(0x07FF); - mscan->idmr3 = SET_IDMR3(0x07FF); - mscan->idmr4 = SET_IDMR4(0x07FF); - mscan->idmr5 = SET_IDMR5(0x07FF); - mscan->idmr6 = SET_IDMR6(0x07FF); - mscan->idmr7 = SET_IDMR7(0x07FF); + /* initialize rx filter masks (16 bit), don't care including rtr */ + mscan->idmr0 = SET_IDMR0(0x7FF); + mscan->idmr1 = SET_IDMR1(0x7FF); + mscan->idmr2 = SET_IDMR2(0x7FF); + mscan->idmr3 = SET_IDMR3(0x7FF); + mscan->idmr4 = SET_IDMR4(0x7FF); + mscan->idmr5 = SET_IDMR5(0x7FF); + mscan->idmr6 = SET_IDMR6(0x7FF); + mscan->idmr7 = SET_IDMR7(0x7FF); /* Control Register 1 --------------------------------------------*/ /* [07]:CANE 0->1 : MSCAN Module is enabled */ @@ -1301,7 +1297,7 @@ rtems_device_driver mscan_write( rtems_device_major_number major, { /* append the TOUCAN tx_id to the mess. due to interrupt handling */ - tx_mess->toucan_tx_id = tx_parms->tx_id; + tx_mess->toucan_tx_idx = tx_parms->tx_idx; /* fill the tx ring buffer with the message */ fill_tx_buffer(chan, tx_mess); @@ -1486,19 +1482,19 @@ rtems_device_driver mscan_control( rtems_device_major_number major, { case RX_BUFFER_0: - ctrl_parms->ctrl_id_mask = GET_IDMR0(mscan->idmr0) | GET_IDMR1(mscan->idmr1); + ctrl_parms->ctrl_id_mask = (GET_IDMR0(mscan->idmr0) | GET_IDMR1(mscan->idmr1)); break; case RX_BUFFER_1: - ctrl_parms->ctrl_id_mask = GET_IDMR2(mscan->idmr2) | GET_IDMR3(mscan->idmr3); + ctrl_parms->ctrl_id_mask = (GET_IDMR2(mscan->idmr2) | GET_IDMR3(mscan->idmr3)); break; case RX_BUFFER_2: - ctrl_parms->ctrl_id_mask = GET_IDMR4(mscan->idmr4) | GET_IDMR5(mscan->idmr5); + ctrl_parms->ctrl_id_mask = (GET_IDMR4(mscan->idmr4) | GET_IDMR5(mscan->idmr5)); break; case RX_BUFFER_3: - ctrl_parms->ctrl_id_mask = GET_IDMR6(mscan->idmr6) | GET_IDMR7(mscan->idmr7); + ctrl_parms->ctrl_id_mask = (GET_IDMR6(mscan->idmr6) | GET_IDMR7(mscan->idmr7)); break; default: diff --git a/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h index dce51137f8..d36c31a105 100644 --- a/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h +++ b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h @@ -17,7 +17,7 @@ | http://www.rtems.com/license/LICENSE. | | | +-----------------------------------------------------------------+ -| this file declares stuff for the mscan driver | +| this file has to be included by application when using mscan | \*===============================================================*/ #ifndef __MSCAN_H__ #define __MSCAN_H__ @@ -26,17 +26,6 @@ extern "C" { #endif -#define MIN_NO_OF_TQ 7 -#define NO_OF_TABLE_ENTRIES 4 -#define TSEG_1 1 -#define TSEG_2 2 -#define SJW 3 - -#define MSCAN_MAX_DATA_BYTES 8 -#define MSCAN_RX_BUFF_NUM 4 -#define MSCAN_TX_BUFF_NUM 3 - - #define MSCAN_A_DEV_NAME "/dev/mscana" #define MSCAN_B_DEV_NAME "/dev/mscanb" #define MSCAN_0_DEV_NAME "/dev/mscan0" @@ -44,20 +33,12 @@ extern "C" { #define MSCAN_A 0 #define MSCAN_B 1 -#define MSCAN_NON_INITIALIZED_MODE 0 -#define MSCAN_INITIALIZED_MODE 1 -#define MSCAN_INIT_NORMAL_MODE 2 -#define MSCAN_NORMAL_MODE 4 -#define MSCAN_SLEEP_MODE 8 - -#define CAN_BIT_RATE_MAX 1000000 -#define CAN_BIT_RATE_MIN 100000 +#define MSCAN_MAX_DATA_BYTES 8 -#define CAN_BIT_RATE 100000 -#define CAN_MAX_NO_OF_TQ 25 -#define CAN_MAX_NO_OF_TQ_TSEG1 15 -#define CAN_MAX_NO_OF_TQ_TSEG2 7 -#define CAN_MAX_NO_OF_TQ_SJW 2 +#define MSCAN_MESS_ID_RTR (1 << 15) +#define MSCAN_MESS_ID_RTR_MASK (1 << 15) +#define MSCAN_MESS_ID_ID_MASK ((1 << 11)-1) +#define MSCAN_MESS_ID_HAS_RTR(id) (((id)&MSCAN_MESS_ID_RTR_MASK)==MSCAN_MESS_ID_RTR) #define MSCAN_SET_RX_ID 1 #define MSCAN_GET_RX_ID 2 @@ -65,187 +46,10 @@ extern "C" { #define MSCAN_GET_RX_ID_MASK 4 #define MSCAN_SET_TX_ID 5 #define MSCAN_GET_TX_ID 6 - #define TOUCAN_MSCAN_INIT 7 #define MSCAN_SET_BAUDRATE 8 #define SET_TX_BUF_NO 9 -#define MSCAN_RX_BUFF_NOACTIVE (0 << 4) -#define MSCAN_RX_BUFF_EMPTY (1 << 6) -#define MSCAN_RX_BUFF_FULL (1 << 5) -#define MSCAN_RX_BUFF_OVERRUN ((MSCAN_RX_BUFF_EMPTY) | (MSCAN_RX_BUFF_FULL)) -#define MSCAN_RX_BUFF_BUSY (1 << 4) - -#define MSCAN_MBUFF_MASK 0x07 - -#define MSCAN_TX_BUFF0 (1 << 0) -#define MSCAN_TX_BUFF1 (1 << 1) -#define MSCAN_TX_BUFF2 (1 << 2) - -#define MSCAN_IDE (1 << 0) -#define MSCAN_RTR (1 << 1) -#define MSCAN_READ_RXBUFF_0 (1 << 2) -#define MSCAN_READ_RXBUFF_1 (1 << 2) -#define MSCAN_READ_RXBUFF_2 (1 << 2) -#define MSCAN_READ_RXBUFF_3 (1 << 2) - -#define CTL0_RXFRM (1 << 7) -#define CTL0_RXACT (1 << 6) -#define CTL0_CSWAI (1 << 5) -#define CTL0_SYNCH (1 << 4) -#define CTL0_TIME (1 << 3) -#define CTL0_WUPE (1 << 2) -#define CTL0_SLPRQ (1 << 1) -#define CTL0_INITRQ (1 << 0) - -#define CTL1_CANE (1 << 7) -#define CTL1_CLKSRC (1 << 6) -#define CTL1_LOOPB (1 << 5) -#define CTL1_LISTEN (1 << 4) -#define CTL1_WUPM (1 << 2) -#define CTL1_SLPAK (1 << 1) -#define CTL1_INITAK (1 << 0) - -#define BTR0_SJW(btr0) ((btr0) << 6) -#define BTR0_BRP(btr0) ((btr0) << 0) - -#define BTR1_SAMP (1 << 7) -#define BTR1_TSEG_22_20(btr1) ((btr1) << 4) -#define BTR1_TSEG_13_10(btr1) ((btr1) << 0) - -#define RFLG_WUPIF (1 << 7) -#define RFLG_CSCIF (1 << 6) -#define RFLG_RSTAT (3 << 4) -#define RFLG_TSTAT (3 << 2) -#define RFLG_OVRIF (1 << 1) -#define RFLG_RXF (1 << 0) -#define RFLG_GET_RX_STATE(rflg) (((rflg) >> 4) & 0x03) -#define RFLG_GET_TX_STATE(rflg) (((rflg) >> 2) & 0x03) - -#define MSCAN_STATE_OK 0 -#define MSCAN_STATE_ERR 1 -#define MSCAN_STATE_WRN 2 -#define MSCAN_STATE_BUSOFF 3 - -#define RIER_WUPIE (1 << 7) -#define RIER_CSCIE (1 << 6) -#define RIER_RSTAT(rier) ((rier) << 4) -#define RIER_TSTAT(rier) ((rier) << 2) -#define RIER_OVRIE (1 << 1) -#define RIER_RXFIE (1 << 0) - -#define TFLG_TXE2 (1 << 2) -#define TFLG_TXE1 (1 << 1) -#define TFLG_TXE0 (1 << 0) - -#define TIER_TXEI2 (1 << 2) -#define TIER_TXEI1 (1 << 1) -#define TIER_TXEI0 (1 << 0) - -#define TARQ_ABTRQ2 (1 << 2) -#define TARQ_ABTRQ1 (1 << 1) -#define TARQ_ABTRQ0 (1 << 0) - -#define TAAK_ABTRQ2 (1 << 2) -#define TAAK_ABTRQ1 (1 << 1) -#define TAAK_ABTRQ0 (1 << 0) - -#define BSEL_TX2 (1 << 2) -#define BSEL_TX1 (1 << 1) -#define BSEL_TX0 (1 << 0) - -#define IDAC_IDAM1 (1 << 5) -#define IDAC_IDAM0 (1 << 4) -#define IDAC_IDHIT(idac) ((idac) & 0x7) - -#define TX_MBUF_SEL(buf_no) (1 << (buf_no)) -#define TX_DATA_LEN(len) ((len) & 0x0F) - -#define TX_MBUF_EMPTY(val) (1 << (val)) - -#define TXIDR1_IDE (1 << 3) -#define TXIDR1_SRR (1 << 4) - -#define TXIDR3_RTR (1 << 0) -#define TXIDR1_RTR (1 << 4) - -#define RXIDR1_IDE (1 << 3) -#define RXIDR1_SRR (1 << 4) - -#define RXIDR3_RTR (1 << 0) -#define RXIDR1_RTR (1 << 4) - -#define SET_IDR0(u16) ((uint8_t)((u16) >> 3)) -#define SET_IDR1(u16) ((uint8_t)(((u16) & 0x0007) << 5)) - -#define SET_IDR2(u16) SET_IDR0(u16) -#define SET_IDR3(u16) SET_IDR1(u16) - -#define SET_IDR4(u16) SET_IDR0(u16) -#define SET_IDR5(u16) SET_IDR1(u16) - -#define SET_IDR6(u16) SET_IDR0(u16) -#define SET_IDR7(u16) SET_IDR1(u16) - -#define GET_IDR0(u16) ((uint16_t) ((u16) << 3)) -#define GET_IDR1(u16) ((uint16_t)(((u16) >> 5)&0x0007)) - -#define GET_IDR2(u16) GET_IDR0(u16) -#define GET_IDR3(u16) GET_IDR1(u16) - -#define GET_IDR4(u16) GET_IDR0(u16) -#define GET_IDR5(u16) GET_IDR1(u16) - -#define GET_IDR6(u16) GET_IDR0(u16) -#define GET_IDR7(u16) GET_IDR1(u16) - -#define SET_IDMR0(u16) ((uint8_t)((u16) >> 3)) -#define SET_IDMR1(u16) ((uint8_t)((((u16) & 0x0007) << 5))|0x001F) - -#define SET_IDMR2(u16) SET_IDMR0(u16) -#define SET_IDMR3(u16) SET_IDMR1(u16) - -#define SET_IDMR4(u16) SET_IDMR0(u16) -#define SET_IDMR5(u16) SET_IDMR1(u16) - -#define SET_IDMR6(u16) SET_IDMR0(u16) -#define SET_IDMR7(u16) SET_IDMR1(u16) - -#define GET_IDMR0(u16) ((uint16_t) ((u16) << 3)) -#define GET_IDMR1(u16) ((uint16_t)(((u16) >> 5)&0x0007)) - -#define GET_IDMR2(u16) GET_IDMR0(u16) -#define GET_IDMR3(u16) GET_IDMR1(u16) - -#define GET_IDMR4(u16) GET_IDMR0(u16) -#define GET_IDMR5(u16) GET_IDMR1(u16) - -#define GET_IDMR6(u16) GET_IDMR0(u16) -#define GET_IDMR7(u16) GET_IDMR1(u16) - -#define NO_OF_MSCAN_RX_BUFF 20 -#define MSCAN_MESSAGE_SIZE(size) (((size)%CPU_ALIGNMENT) ? (((size) + CPU_ALIGNMENT)-((size) + CPU_ALIGNMENT)%CPU_ALIGNMENT) : (size)) - -#define TX_BUFFER_0 0 -#define TX_BUFFER_1 1 -#define TX_BUFFER_2 2 - -#define RX_BUFFER_0 0 -#define RX_BUFFER_1 1 -#define RX_BUFFER_2 2 -#define RX_BUFFER_3 3 - -#define NO_OF_MSCAN_TX_BUFF 20 -#define RING_BUFFER_EMPTY(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) -#define RING_BUFFER_FULL(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) - - -typedef struct _mscan_handle - { - uint8_t mscan_channel; - void (*toucan_callback)(int16_t); - } mscan_handle; - struct can_message { /* uint16_t mess_len; */ @@ -253,33 +57,8 @@ struct can_message uint16_t mess_time_stamp; uint8_t mess_data[MSCAN_MAX_DATA_BYTES]; uint8_t mess_len; - uint32_t toucan_tx_id; - }; - -struct ring_buf - { - struct can_message * volatile buf_ptr; - struct can_message * volatile head_ptr; - struct can_message * volatile tail_ptr; - }; - -struct mpc5200_rx_cntrl - { - struct can_message can_rx_message[MSCAN_RX_BUFF_NUM]; - }; - -struct mscan_channel_info - { - volatile struct mpc5200_mscan *regs; - uint32_t int_rx_err; - rtems_id rx_qid; - uint32_t rx_qname; - rtems_id tx_rb_sid; - uint32_t tx_rb_sname; - uint8_t id_extended; - uint8_t mode; - uint8_t tx_buf_no; - struct ring_buf tx_ring_buf; + uint8_t mess_rtr; + uint32_t toucan_tx_idx; }; struct mscan_rx_parms @@ -292,7 +71,7 @@ struct mscan_rx_parms struct mscan_tx_parms { struct can_message *tx_mess; - uint32_t tx_id; + uint32_t tx_idx; }; struct mscan_ctrl_parms @@ -306,10 +85,6 @@ struct mscan_ctrl_parms }; -extern void CanInterrupt_A(int16_t); -extern void CanInterrupt_B(int16_t); - - rtems_device_driver mscan_initialize( rtems_device_major_number, rtems_device_minor_number, void * @@ -345,23 +120,6 @@ rtems_device_driver mscan_control( rtems_device_major_number, { mscan_initialize, mscan_open, mscan_close, \ mscan_read, mscan_write, mscan_control } -/*MSCAN driver internal functions */ -void mscan_hardware_initialize(rtems_device_major_number, uint32_t, void *); -void mpc5200_mscan_int_enable(volatile struct mpc5200_mscan *); -void mpc5200_mscan_int_disable(volatile struct mpc5200_mscan *); -void mpc5200_mscan_enter_sleep_mode(volatile struct mpc5200_mscan *); -void mpc5200_mscan_exit_sleep_mode(volatile struct mpc5200_mscan *); -void mpc5200_mscan_enter_init_mode(volatile struct mpc5200_mscan *); -void mpc5200_mscan_exit_init_mode(volatile struct mpc5200_mscan *); -void mpc5200_mscan_wait_sync(volatile struct mpc5200_mscan *); -void mpc5200_mscan_perform_init_mode_settings(volatile struct mpc5200_mscan *); -void mpc5200_mscan_perform_normal_mode_settings(volatile struct mpc5200_mscan *); -rtems_status_code mpc5200_mscan_set_mode(rtems_device_minor_number, uint8_t); -rtems_status_code mscan_channel_initialize(rtems_device_major_number, rtems_device_minor_number); -uint8_t prescaler_calculation(uint32_t, uint32_t, uint8_t *); -void mpc5200_mscan_perform_bit_time_settings(volatile struct mpc5200_mscan *, uint32_t, uint32_t); - - #ifdef __cplusplus } #endif diff --git a/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan_int.h b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan_int.h new file mode 100644 index 0000000000..e699c97d51 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/gen5200/mscan/mscan_int.h @@ -0,0 +1,271 @@ +/*===============================================================*\ +| Project: RTEMS generic MPC5200 BSP | ++-----------------------------------------------------------------+ +| Partially based on the code references which are named below. | +| Adaptions, modifications, enhancements and any recent parts of | +| the code are: | +| Copyright (c) 2005 | +| Embedded Brains GmbH | +| Obere Lagerstr. 30 | +| D-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. | +| | ++-----------------------------------------------------------------+ +| this file has to be included by the mscan driver | +\*===============================================================*/ +#ifndef __MSCAN_INT_H__ +#define __MSCAN_INT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../mscan/mscan.h" + +#define MIN_NO_OF_TQ 7 +#define NO_OF_TABLE_ENTRIES 4 +#define TSEG_1 1 +#define TSEG_2 2 +#define SJW 3 + +#define MSCAN_RX_BUFF_NUM 4 +#define MSCAN_TX_BUFF_NUM 3 + +#define MSCAN_NON_INITIALIZED_MODE 0 +#define MSCAN_INITIALIZED_MODE 1 +#define MSCAN_INIT_NORMAL_MODE 2 +#define MSCAN_NORMAL_MODE 4 +#define MSCAN_SLEEP_MODE 8 + +#define CAN_BIT_RATE_MAX 1000000 +#define CAN_BIT_RATE_MIN 100000 + +#define CAN_BIT_RATE 100000 +#define CAN_MAX_NO_OF_TQ 25 +#define CAN_MAX_NO_OF_TQ_TSEG1 15 +#define CAN_MAX_NO_OF_TQ_TSEG2 7 +#define CAN_MAX_NO_OF_TQ_SJW 2 + +#define MSCAN_RX_BUFF_NOACTIVE (0 << 4) +#define MSCAN_RX_BUFF_EMPTY (1 << 6) +#define MSCAN_RX_BUFF_FULL (1 << 5) +#define MSCAN_RX_BUFF_OVERRUN ((MSCAN_RX_BUFF_EMPTY) | (MSCAN_RX_BUFF_FULL)) +#define MSCAN_RX_BUFF_BUSY (1 << 4) + +#define MSCAN_MBUFF_MASK 0x07 + +#define MSCAN_TX_BUFF0 (1 << 0) +#define MSCAN_TX_BUFF1 (1 << 1) +#define MSCAN_TX_BUFF2 (1 << 2) + +#define MSCAN_IDE (1 << 0) +#define MSCAN_RTR (1 << 1) +#define MSCAN_READ_RXBUFF_0 (1 << 2) +#define MSCAN_READ_RXBUFF_1 (1 << 2) +#define MSCAN_READ_RXBUFF_2 (1 << 2) +#define MSCAN_READ_RXBUFF_3 (1 << 2) + +#define CTL0_RXFRM (1 << 7) +#define CTL0_RXACT (1 << 6) +#define CTL0_CSWAI (1 << 5) +#define CTL0_SYNCH (1 << 4) +#define CTL0_TIME (1 << 3) +#define CTL0_WUPE (1 << 2) +#define CTL0_SLPRQ (1 << 1) +#define CTL0_INITRQ (1 << 0) + +#define CTL1_CANE (1 << 7) +#define CTL1_CLKSRC (1 << 6) +#define CTL1_LOOPB (1 << 5) +#define CTL1_LISTEN (1 << 4) +#define CTL1_WUPM (1 << 2) +#define CTL1_SLPAK (1 << 1) +#define CTL1_INITAK (1 << 0) + +#define BTR0_SJW(btr0) ((btr0) << 6) +#define BTR0_BRP(btr0) ((btr0) << 0) + +#define BTR1_SAMP (1 << 7) +#define BTR1_TSEG_22_20(btr1) ((btr1) << 4) +#define BTR1_TSEG_13_10(btr1) ((btr1) << 0) + +#define RFLG_WUPIF (1 << 7) +#define RFLG_CSCIF (1 << 6) +#define RFLG_RSTAT (3 << 4) +#define RFLG_TSTAT (3 << 2) +#define RFLG_OVRIF (1 << 1) +#define RFLG_RXF (1 << 0) +#define RFLG_GET_RX_STATE(rflg) (((rflg) >> 4) & 0x03) +#define RFLG_GET_TX_STATE(rflg) (((rflg) >> 2) & 0x03) + +#define MSCAN_STATE_OK 0 +#define MSCAN_STATE_ERR 1 +#define MSCAN_STATE_WRN 2 +#define MSCAN_STATE_BUSOFF 3 + +#define RIER_WUPIE (1 << 7) +#define RIER_CSCIE (1 << 6) +#define RIER_RSTAT(rier) ((rier) << 4) +#define RIER_TSTAT(rier) ((rier) << 2) +#define RIER_OVRIE (1 << 1) +#define RIER_RXFIE (1 << 0) + +#define TFLG_TXE2 (1 << 2) +#define TFLG_TXE1 (1 << 1) +#define TFLG_TXE0 (1 << 0) + +#define TIER_TXEI2 (1 << 2) +#define TIER_TXEI1 (1 << 1) +#define TIER_TXEI0 (1 << 0) + +#define TARQ_ABTRQ2 (1 << 2) +#define TARQ_ABTRQ1 (1 << 1) +#define TARQ_ABTRQ0 (1 << 0) + +#define TAAK_ABTRQ2 (1 << 2) +#define TAAK_ABTRQ1 (1 << 1) +#define TAAK_ABTRQ0 (1 << 0) + +#define BSEL_TX2 (1 << 2) +#define BSEL_TX1 (1 << 1) +#define BSEL_TX0 (1 << 0) + +#define IDAC_IDAM1 (1 << 5) +#define IDAC_IDAM0 (1 << 4) +#define IDAC_IDHIT(idac) ((idac) & 0x7) + +#define TX_MBUF_SEL(buf_no) (1 << (buf_no)) +#define TX_DATA_LEN(len) ((len) & 0x0F) + +#define TX_MBUF_EMPTY(val) (1 << (val)) + +#define ID_RTR (1 << 4) + +#define SET_IDR0(u16) ((uint8_t)((u16) >> 3)) +#define SET_IDR1(u16) (MSCAN_MESS_ID_HAS_RTR(u16) ? ((uint8_t)(((u16) & 0x0007) << 5))|((uint8_t)(ID_RTR)) : ((uint8_t)(((u16) & 0x0007) << 5))) + +#define SET_IDR2(u16) SET_IDR0(u16) +#define SET_IDR3(u16) SET_IDR1(u16) + +#define SET_IDR4(u16) SET_IDR0(u16) +#define SET_IDR5(u16) SET_IDR1(u16) + +#define SET_IDR6(u16) SET_IDR0(u16) +#define SET_IDR7(u16) SET_IDR1(u16) + +#define GET_IDR0(u16) ((uint16_t) ((u16) << 3)) +#define GET_IDR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007)) + +#define GET_IDR2(u16) GET_IDR0(u16) +#define GET_IDR3(u16) GET_IDR1(u16) + +#define GET_IDR4(u16) GET_IDR0(u16) +#define GET_IDR5(u16) GET_IDR1(u16) + +#define GET_IDR6(u16) GET_IDR0(u16) +#define GET_IDR7(u16) GET_IDR1(u16) + +#define SET_IDMR0(u16) ((uint8_t)((u16) >> 3)) +#define SET_IDMR1(u16) (MSCAN_MESS_ID_HAS_RTR(u16) ? ((uint8_t) (((((u16) & 0x0007) << 5)|((uint8_t)(ID_RTR)))|0x0007)) : ((uint8_t)((((u16) & 0x0007) << 5))|0x0007)) + +#define SET_IDMR2(u16) SET_IDMR0(u16) +#define SET_IDMR3(u16) SET_IDMR1(u16) + +#define SET_IDMR4(u16) SET_IDMR0(u16) +#define SET_IDMR5(u16) SET_IDMR1(u16) + +#define SET_IDMR6(u16) SET_IDMR0(u16) +#define SET_IDMR7(u16) SET_IDMR1(u16) + +#define GET_IDMR0(u16) ((uint16_t)((u16) << 3)) +#define GET_IDMR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007)) + +#define GET_IDMR2(u16) GET_IDMR0(u16) +#define GET_IDMR3(u16) GET_IDMR1(u16) + +#define GET_IDMR4(u16) GET_IDMR0(u16) +#define GET_IDMR5(u16) GET_IDMR1(u16) + +#define GET_IDMR6(u16) GET_IDMR0(u16) +#define GET_IDMR7(u16) GET_IDMR1(u16) + +#define NO_OF_MSCAN_RX_BUFF 20 +#define MSCAN_MESSAGE_SIZE(size) (((size)%CPU_ALIGNMENT) ? (((size) + CPU_ALIGNMENT)-((size) + CPU_ALIGNMENT)%CPU_ALIGNMENT) : (size)) + +#define TX_BUFFER_0 0 +#define TX_BUFFER_1 1 +#define TX_BUFFER_2 2 + +#define RX_BUFFER_0 0 +#define RX_BUFFER_1 1 +#define RX_BUFFER_2 2 +#define RX_BUFFER_3 3 + +#define NO_OF_MSCAN_TX_BUFF 20 +#define RING_BUFFER_EMPTY(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) +#define RING_BUFFER_FULL(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) + + +typedef struct _mscan_handle + { + uint8_t mscan_channel; + void (*toucan_callback)(int16_t); + } mscan_handle; + +struct ring_buf + { + struct can_message * volatile buf_ptr; + struct can_message * volatile head_ptr; + struct can_message * volatile tail_ptr; + }; + +struct mpc5200_rx_cntrl + { + struct can_message can_rx_message[MSCAN_RX_BUFF_NUM]; + }; + +struct mscan_channel_info + { + volatile struct mpc5200_mscan *regs; + uint32_t int_rx_err; + rtems_id rx_qid; + uint32_t rx_qname; + rtems_id tx_rb_sid; + uint32_t tx_rb_sname; + uint8_t id_extended; + uint8_t mode; + uint8_t tx_buf_no; + struct ring_buf tx_ring_buf; + }; + +extern void CanInterrupt_A(int16_t); +extern void CanInterrupt_B(int16_t); + +/*MSCAN driver internal functions */ +void mscan_hardware_initialize(rtems_device_major_number, uint32_t, void *); +void mpc5200_mscan_int_enable(volatile struct mpc5200_mscan *); +void mpc5200_mscan_int_disable(volatile struct mpc5200_mscan *); +void mpc5200_mscan_enter_sleep_mode(volatile struct mpc5200_mscan *); +void mpc5200_mscan_exit_sleep_mode(volatile struct mpc5200_mscan *); +void mpc5200_mscan_enter_init_mode(volatile struct mpc5200_mscan *); +void mpc5200_mscan_exit_init_mode(volatile struct mpc5200_mscan *); +void mpc5200_mscan_wait_sync(volatile struct mpc5200_mscan *); +void mpc5200_mscan_perform_init_mode_settings(volatile struct mpc5200_mscan *); +void mpc5200_mscan_perform_normal_mode_settings(volatile struct mpc5200_mscan *); +rtems_status_code mpc5200_mscan_set_mode(rtems_device_minor_number, uint8_t); +rtems_status_code mscan_channel_initialize(rtems_device_major_number, rtems_device_minor_number); +uint8_t prescaler_calculation(uint32_t, uint32_t, uint8_t *); +void mpc5200_mscan_perform_bit_time_settings(volatile struct mpc5200_mscan *, uint32_t, uint32_t); + + +#ifdef __cplusplus +} +#endif + +#endif /* __MSCAN_H__ */ diff --git a/c/src/libchip/ide/ata.c b/c/src/libchip/ide/ata.c index 6c765262e7..abcd375c62 100644 --- a/c/src/libchip/ide/ata.c +++ b/c/src/libchip/ide/ata.c @@ -528,15 +528,16 @@ ata_request_done(ata_req_t *areq, rtems_device_minor_number ctrl_minor, DISABLE_PREEMPTION(key); ATA_EXEC_CALLBACK(areq, status, error); Chain_Extract(&areq->link); - free(areq); if (!Chain_Is_empty(&ata_ide_ctrls[ctrl_minor].reqs)) { ENABLE_PREEMPTION(key); + free(areq); ata_process_request(ctrl_minor); return; } ENABLE_PREEMPTION(key); + free(areq); } /* ata_non_data_request_done -- diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 3faad90561..62f4b37ecd 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,10 @@ +2007-01-20 Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> + + * libblock/src/bdbuf.c: + * libblock/include/bdbuf.h: + export some internal variables to make them available in + "show_bdbuf" monitor add-on + 2007-01-16 Till Straumann <strauman@slac.stanford.edu> * libnetworking/rtems/rtems_mii_ioctl.c, * libnetworking/rtems/rtems_mii_ioctl.h, diff --git a/cpukit/libblock/Makefile.am b/cpukit/libblock/Makefile.am index 27301ce91a..5f88af25b0 100644 --- a/cpukit/libblock/Makefile.am +++ b/cpukit/libblock/Makefile.am @@ -8,7 +8,8 @@ include $(top_srcdir)/automake/compile.am if !UNIX noinst_LIBRARIES = libblock.a libblock_a_SOURCES = src/bdbuf.c src/blkdev.c src/diskdevs.c src/ramdisk.c \ - src/ide_part_table.c include/rtems/bdbuf.h include/rtems/blkdev.h \ + src/ide_part_table.c src/show_bdbuf.c \ + include/rtems/bdbuf.h include/rtems/blkdev.h \ include/rtems/diskdevs.h include/rtems/ramdisk.h \ include/rtems/ide_part_table.h endif diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h index c966b2836e..f4308963dd 100644 --- a/cpukit/libblock/include/rtems/bdbuf.h +++ b/cpukit/libblock/include/rtems/bdbuf.h @@ -8,7 +8,7 @@ * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia * Author: Victor V. Vengerov <vvv@oktet.ru> * - * @(#) $Id$ + * @(#) bdbuf.h,v 1.9 2005/02/02 00:06:18 joel Exp */ #ifndef _RTEMS_BDBUF_H @@ -74,6 +74,48 @@ typedef struct bdbuf_buffer { } bdbuf_buffer; +/* + * the following data structures are internal to the bdbuf layer, + * but it is convenient to have them visible from the outside for inspection + */ +/* + * The groups of the blocks with the same size are collected in the + * bd_pool. Note that a several of the buffer's groups with the + * same size can exists. + */ +typedef struct bdbuf_pool +{ + bdbuf_buffer *tree; /* Buffer descriptor lookup AVL tree root */ + + Chain_Control free; /* Free buffers list */ + Chain_Control lru; /* Last recently used list */ + + int blksize; /* The size of the blocks (in bytes) */ + int nblks; /* Number of blocks in this pool */ + rtems_id bufget_sema; /* Buffer obtain counting semaphore */ + void *mallocd_bufs; /* Pointer to the malloc'd buffer memory, + or NULL, if buffer memory provided in + buffer configuration */ + bdbuf_buffer *bdbufs; /* Pointer to table of buffer descriptors + allocated for this buffer pool. */ +} bdbuf_pool; + +/* Buffering layer context definition */ +struct bdbuf_context { + bdbuf_pool *pool; /* Table of buffer pools */ + int npools; /* Number of entries in pool table */ + + Chain_Control mod; /* Modified buffers list */ + rtems_id flush_sema; /* Buffer flush semaphore; counting + semaphore; incremented when buffer + flushed to the disk; decremented when + buffer modified */ + rtems_id swapout_task; /* Swapout task ID */ +}; + /* + * the context of the buffering layer, visible for inspection + */ +extern struct bdbuf_context rtems_bdbuf_ctx; /* bdbuf_config structure describes block configuration (size, * amount, memory location) for buffering layer diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c index 8fb7d515be..f695ede2ab 100644 --- a/cpukit/libblock/src/bdbuf.c +++ b/cpukit/libblock/src/bdbuf.c @@ -7,7 +7,7 @@ * Victor V. Vengerov <vvv@oktet.ru> * Alexander Kukuta <kam@oktet.ru> * - * @(#) $Id$ + * @(#) bdbuf.c,v 1.14 2004/04/17 08:15:17 ralf Exp */ #if HAVE_CONFIG_H @@ -56,40 +56,6 @@ static rtems_task bdbuf_swapout_task(rtems_task_argument unused); static rtems_status_code bdbuf_release(bdbuf_buffer *bd_buf); /* - * The groups of the blocks with the same size are collected in the - * bd_pool. Note that a several of the buffer's groups with the - * same size can exists. - */ -typedef struct bdbuf_pool -{ - bdbuf_buffer *tree; /* Buffer descriptor lookup AVL tree root */ - - Chain_Control free; /* Free buffers list */ - Chain_Control lru; /* Last recently used list */ - - int blksize; /* The size of the blocks (in bytes) */ - int nblks; /* Number of blocks in this pool */ - rtems_id bufget_sema; /* Buffer obtain counting semaphore */ - void *mallocd_bufs; /* Pointer to the malloc'd buffer memory, - or NULL, if buffer memory provided in - buffer configuration */ - bdbuf_buffer *bdbufs; /* Pointer to table of buffer descriptors - allocated for this buffer pool. */ -} bdbuf_pool; - -/* Buffering layer context definition */ -struct bdbuf_context { - bdbuf_pool *pool; /* Table of buffer pools */ - int npools; /* Number of entries in pool table */ - - Chain_Control mod; /* Modified buffers list */ - rtems_id flush_sema; /* Buffer flush semaphore; counting - semaphore; incremented when buffer - flushed to the disk; decremented when - buffer modified */ - rtems_id swapout_task; /* Swapout task ID */ -}; -/* * maximum number of blocks that might be chained together to one * write driver call */ @@ -108,8 +74,8 @@ typedef struct blkdev_request1 { blkdev_sg_buffer sg[1]; } blkdev_request1; -/* The static context of buffering layer */ -static struct bdbuf_context bd_ctx; +/* The context of buffering layer */ +struct bdbuf_context rtems_bdbuf_ctx; #define SAFE #ifdef SAFE @@ -711,7 +677,7 @@ avl_remove(bdbuf_buffer **root, const bdbuf_buffer *node) static rtems_status_code bdbuf_initialize_pool(rtems_bdbuf_config *config, int pool) { - bdbuf_pool *p = bd_ctx.pool + pool; + bdbuf_pool *p = rtems_bdbuf_ctx.pool + pool; unsigned char *bufs; bdbuf_buffer *b; rtems_status_code rc; @@ -787,7 +753,7 @@ bdbuf_initialize_pool(rtems_bdbuf_config *config, int pool) static rtems_status_code bdbuf_release_pool(rtems_bdpool_id pool) { - bdbuf_pool *p = bd_ctx.pool + pool; + bdbuf_pool *p = rtems_bdbuf_ctx.pool + pool; rtems_semaphore_delete(p->bufget_sema); free(p->bdbufs); free(p->mallocd_bufs); @@ -818,18 +784,18 @@ rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size) if (size <= 0) return RTEMS_INVALID_SIZE; - bd_ctx.npools = size; + rtems_bdbuf_ctx.npools = size; /* * Allocate memory for buffer pool descriptors */ - bd_ctx.pool = calloc(size, sizeof(bdbuf_pool)); - if (bd_ctx.pool == NULL) + rtems_bdbuf_ctx.pool = calloc(size, sizeof(bdbuf_pool)); + if (rtems_bdbuf_ctx.pool == NULL) { return RTEMS_NO_MEMORY; } - Chain_Initialize_empty(&bd_ctx.mod); + Chain_Initialize_empty(&rtems_bdbuf_ctx.mod); /* Initialize buffer pools and roll out if something failed */ for (i = 0; i < size; i++) @@ -851,12 +817,12 @@ rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size) rtems_build_name('B', 'F', 'L', 'U'), 0, RTEMS_FIFO | RTEMS_COUNTING_SEMAPHORE | RTEMS_NO_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL, 0, - &bd_ctx.flush_sema); + &rtems_bdbuf_ctx.flush_sema); if (rc != RTEMS_SUCCESSFUL) { for (i = 0; i < size; i++) bdbuf_release_pool(i); - free(bd_ctx.pool); + free(rtems_bdbuf_ctx.pool); return rc; } @@ -869,24 +835,24 @@ rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size) SWAPOUT_TASK_STACK_SIZE, RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, - &bd_ctx.swapout_task); + &rtems_bdbuf_ctx.swapout_task); if (rc != RTEMS_SUCCESSFUL) { - rtems_semaphore_delete(bd_ctx.flush_sema); + rtems_semaphore_delete(rtems_bdbuf_ctx.flush_sema); for (i = 0; i < size; i++) bdbuf_release_pool(i); - free(bd_ctx.pool); + free(rtems_bdbuf_ctx.pool); return rc; } - rc = rtems_task_start(bd_ctx.swapout_task, bdbuf_swapout_task, 0); + rc = rtems_task_start(rtems_bdbuf_ctx.swapout_task, bdbuf_swapout_task, 0); if (rc != RTEMS_SUCCESSFUL) { - rtems_task_delete(bd_ctx.swapout_task); - rtems_semaphore_delete(bd_ctx.flush_sema); + rtems_task_delete(rtems_bdbuf_ctx.swapout_task); + rtems_semaphore_delete(rtems_bdbuf_ctx.flush_sema); for (i = 0; i < size; i++) bdbuf_release_pool(i); - free(bd_ctx.pool); + free(rtems_bdbuf_ctx.pool); return rc; } @@ -933,7 +899,7 @@ find_or_assign_buffer(disk_device *dd, int blksize; device = dd->dev; - bd_pool = bd_ctx.pool + dd->pool; + bd_pool = rtems_bdbuf_ctx.pool + dd->pool; blksize = dd->block_size; again: @@ -1021,7 +987,7 @@ again: * that our buffer descriptor is in the list. */ if (bd_buf->modified) { - rc = rtems_semaphore_obtain(bd_ctx.flush_sema, + rc = rtems_semaphore_obtain(rtems_bdbuf_ctx.flush_sema, RTEMS_NO_WAIT, 0); } else @@ -1476,7 +1442,7 @@ bdbuf_release(bdbuf_buffer *bd_buf) if (bd_buf->use_count <= 0) return RTEMS_INTERNAL_ERROR; - bd_pool = bd_ctx.pool + bd_buf->pool; + bd_pool = rtems_bdbuf_ctx.pool + bd_buf->pool; bd_buf->use_count--; @@ -1487,10 +1453,10 @@ bdbuf_release(bdbuf_buffer *bd_buf) /* Buffer was modified. Insert buffer to the modified buffers * list and initiate flushing. */ - Chain_Append(&bd_ctx.mod, &bd_buf->link); + Chain_Append(&rtems_bdbuf_ctx.mod, &bd_buf->link); /* Release the flush_sema */ - rc = rtems_semaphore_release(bd_ctx.flush_sema); + rc = rtems_semaphore_release(rtems_bdbuf_ctx.flush_sema); } else { @@ -1659,7 +1625,7 @@ rtems_bdbuf_syncdev(dev_t dev) if (dd == NULL) return RTEMS_INVALID_ID; - pool = bd_ctx.pool + dd->pool; + pool = rtems_bdbuf_ctx.pool + dd->pool; DISABLE_PREEMPTION(key); do { @@ -1718,13 +1684,13 @@ bdbuf_swapout_task(rtems_task_argument unused) * otherwise do not wait, if no buffer available */ if (nxt_bd_buf == NULL) { - rc = rtems_semaphore_obtain(bd_ctx.flush_sema, + rc = rtems_semaphore_obtain(rtems_bdbuf_ctx.flush_sema, (req.req.count == 0) ? RTEMS_WAIT : RTEMS_NO_WAIT, 0); if (rc == RTEMS_SUCCESSFUL) { - nxt_bd_buf = (bdbuf_buffer *)Chain_Get(&bd_ctx.mod); + nxt_bd_buf = (bdbuf_buffer *)Chain_Get(&rtems_bdbuf_ctx.mod); if (nxt_bd_buf != NULL) { nxt_bd_buf->in_progress = TRUE; /* IMD try: clear "modified" bit early */ @@ -1764,7 +1730,7 @@ bdbuf_swapout_task(rtems_task_argument unused) * for next main loop */ if (bd_buf != NULL) { - bd_pool = bd_ctx.pool + bd_buf->pool; + bd_pool = rtems_bdbuf_ctx.pool + bd_buf->pool; if (req.req.count == 0) { /* * this is the first block, so use its address @@ -1818,8 +1784,8 @@ bdbuf_swapout_task(rtems_task_argument unused) { if (bd_buf->modified) { - Chain_Append(&bd_ctx.mod, &bd_buf->link); - rc = rtems_semaphore_release(bd_ctx.flush_sema); + Chain_Append(&rtems_bdbuf_ctx.mod, &bd_buf->link); + rc = rtems_semaphore_release(rtems_bdbuf_ctx.flush_sema); } else { @@ -1860,7 +1826,7 @@ rtems_bdbuf_find_pool(int block_size, rtems_bdpool_id *pool) if (j != 1) return RTEMS_INVALID_SIZE; - for (i = 0, p = bd_ctx.pool; i < bd_ctx.npools; i++, p++) + for (i = 0, p = rtems_bdbuf_ctx.pool; i < rtems_bdbuf_ctx.npools; i++, p++) { if ((p->blksize >= block_size) && (p->blksize < cursize)) @@ -1903,17 +1869,17 @@ rtems_status_code rtems_bdbuf_get_pool_info(rtems_bdpool_id pool, int *block_size, int *blocks) { - if (pool >= bd_ctx.npools) + if (pool >= rtems_bdbuf_ctx.npools) return RTEMS_INVALID_NUMBER; if (block_size != NULL) { - *block_size = bd_ctx.pool[pool].blksize; + *block_size = rtems_bdbuf_ctx.pool[pool].blksize; } if (blocks != NULL) { - *blocks = bd_ctx.pool[pool].nblks; + *blocks = rtems_bdbuf_ctx.pool[pool].nblks; } return RTEMS_SUCCESSFUL; diff --git a/cpukit/libblock/src/show_bdbuf.c b/cpukit/libblock/src/show_bdbuf.c new file mode 100644 index 0000000000..0deb28e854 --- /dev/null +++ b/cpukit/libblock/src/show_bdbuf.c @@ -0,0 +1,904 @@ +/*===============================================================*\
+| Project: RTEMS bdbuf inspector |
++-----------------------------------------------------------------+
+| File: show_bdbuf.c
++-----------------------------------------------------------------+
+| Copyright (c) 2005 |
+| Embedded Brains GmbH |
+| Obere Lagerstr. 30 |
+| D-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. |
+| |
++-----------------------------------------------------------------+
+| this file contains functions to enable the monitor |
+| to show bdbuf information |
+| |
+| XXX!!! ATTETION!!! XXX!!! |
+| |
+| This module inspects the bdbuf data structures, |
+| assuming they are static, but in fact they are used very |
+| dynamically. Therefore the results show MAY BE INCORRECT in |
+| some cases. And, to cure this a bit, this module may block |
+| preemption for a rather long time and therefore it may |
+| BREAK THE REALTIME BEHAVIOUR OF YOUR SYSTEM (when in use) |
++-----------------------------------------------------------------+
+| date history ID |
+| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
+| 26.09.06 creation doe |
+|*****************************************************************|
+\*===============================================================*/
+#include <rtems.h>
+#include <rtems/monitor.h>
+#include <rtems/bdbuf.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <rtems/libio.h>
+
+
+typedef struct {
+ boolean bdbuf_modified;
+ boolean bdbuf_in_progress;
+ boolean bdbuf_actual;
+ boolean bdbuf_used;
+ boolean bdbuf_all;
+ rtems_bdpool_id pool_id;
+} show_bdbuf_filter_t;
+
+typedef struct {
+ boolean show_all;
+ boolean show_node_chain;
+ boolean show_dev;
+ boolean show_blocknum;
+ boolean show_error;
+ boolean show_state;
+ boolean show_use_count;
+ boolean show_pool_id;
+ boolean show_sema;
+} show_bdbuf_selector_t;
+
+typedef enum {bdbuf_chain_ident_none,
+ bdbuf_chain_ident_free,
+ bdbuf_chain_ident_lru,
+ bdbuf_chain_ident_mod} bdbuf_chain_identifier_t;
+
+typedef struct {
+ rtems_bdpool_id pool_id;
+ int index;
+ bdbuf_chain_identifier_t in_chain;
+ dev_t dev;
+ blkdev_bnum blknum;
+ rtems_status_code status;
+ int error;
+ boolean modified;
+ boolean in_progress;
+ boolean actual;
+ int use_count;
+ const CORE_mutex_Control *sema;
+} show_bdbuf_bdbuf_info_t;
+
+typedef rtems_mode preemption_key_t;
+#define DISABLE_PREEMPTION(key) \
+ do { \
+ rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &(key)); \
+ } while (0)
+
+#define ENABLE_PREEMPTION(key) \
+ do { \
+ rtems_mode temp; \
+ rtems_task_mode((key), RTEMS_PREEMPT_MASK, &temp); \
+ } while (0)
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_follow_chain_node_to_head
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| follow a given chain to its head |
+| XXX: this is executed with preemption disabled |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const Chain_Node *the_node, /* input: node to track to its head */
+ Chain_Control **the_head /* storage for pointer to chain head */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+ preemption_key_t preempt_key;
+ boolean preempt_disabled = FALSE;
+ /*
+ * disable preemption
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ DISABLE_PREEMPTION(preempt_key);
+ }
+ /*
+ * follow node to its head
+ * XXX: this is highly dependent on the chain implementation
+ * in score/src/chain.c and friends
+ */
+ while (the_node->previous != NULL) {
+ the_node = the_node->previous;
+ }
+ /*
+ * reenable preemption, if disabled
+ */
+ if (preempt_disabled) {
+ ENABLE_PREEMPTION(preempt_key);
+ }
+ /*
+ * XXX: this depends n the chain implementation in
+ * score/include/rtems/score/chain.h:
+ * Chain_Control is overlayed by two Cohain_Nodes
+ */
+ *the_head = (Chain_Control *)the_node;
+
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_determine_chain_of_bdbuf
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| find out, which chain this bdbuf is linked in |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const bdbuf_buffer *the_bdbuf, /* this is the bdbuf structure */
+ const bdbuf_pool *curr_pool, /* the pool this buffer belongs to */
+ bdbuf_chain_identifier_t *chn_ident /* result: identifier for chain */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+ Chain_Control *the_chain_control;
+
+
+ *chn_ident = bdbuf_chain_ident_none;
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_bdbuf_show_follow_chain_node_to_head(&(the_bdbuf->link),
+ &(the_chain_control));
+ }
+ if (rc == RTEMS_SUCCESSFUL) {
+ if (the_chain_control == &(curr_pool->free)) {
+ *chn_ident = bdbuf_chain_ident_free;
+ }
+ else if (the_chain_control == &(curr_pool->lru)) {
+ *chn_ident = bdbuf_chain_ident_lru;
+ }
+ else if (the_chain_control == &(rtems_bdbuf_ctx.mod)) {
+ *chn_ident = bdbuf_chain_ident_mod;
+ }
+ }
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_getargs
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| analyze cmd arguments |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ int argc,
+ char **argv,
+ show_bdbuf_filter_t *filter,
+ show_bdbuf_selector_t *selector
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ int arg_error = 0;
+ int i;
+ char *tmp_ptr;
+ int nm_argc = 0;
+ /*
+ * set filter and selector to default
+ */
+ memset(filter,0,sizeof(*filter));
+ filter->bdbuf_all = TRUE;
+ memset(selector,0,sizeof(*selector));
+ selector->show_all = TRUE;
+
+ /*
+ * scan arguments
+ */
+ for (i = 1;
+ (i < argc) && (arg_error == 0);
+ i++) {
+ if (argv[i][0] == '-') {
+ /*
+ * modifier arguments
+ */
+ switch(tolower(argv[i][1])) {
+ /*
+ * selection, which bdbufs to show
+ */
+ case 'm': /* only show bdbufs modified */
+ filter->bdbuf_modified = TRUE ;
+ filter->bdbuf_all = FALSE;
+ break;
+ case 'i': /* only show bdbufs in progress*/
+ filter->bdbuf_in_progress = TRUE ;
+ filter->bdbuf_all = FALSE;
+ break;
+ case 'v': /* only show bdbufs, which have valid data*/
+ filter->bdbuf_actual = TRUE ;
+ filter->bdbuf_all = FALSE;
+ break;
+ case 'u': /* only show bdbufs, which are in use */
+ filter->bdbuf_used = TRUE ;
+ filter->bdbuf_all = FALSE;
+ break;
+ case 'p': /* only show bdbufs, which belong to pool <n> */
+ filter->pool_id = strtol(argv[i]+2,&tmp_ptr,0);
+ if (tmp_ptr == argv[i]+2) { /* no conversion performed... */
+ arg_error = i;
+ }
+ filter->bdbuf_all = FALSE;
+ break;
+ /*
+ * selection, what fields to show
+ */
+ case 'n': /* show bdbuf node_chain */
+ selector->show_node_chain = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 'd': /* show device */
+ selector->show_dev = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 'b': /* show blocknum */
+ selector->show_blocknum = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 'e': /* show bdbuf error status */
+ selector->show_error = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 's': /* show bdbuf state */
+ selector->show_state = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 'c': /* show bdbuf use count */
+ selector->show_use_count = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 'l': /* show bdbuf pool id */
+ selector->show_pool_id = TRUE ;
+ selector->show_all = FALSE;
+ break;
+ case 't': /* show bdbuf transfer sema */
+ selector->show_sema = TRUE ;
+ break;
+ default:
+ arg_error = i;
+ break;
+ }
+ }
+ else {
+ /*
+ * non-modifier arguments
+ */
+ switch(++nm_argc) {
+ default: /* no further arguments defined */
+ arg_error = i;
+ break;
+ }
+ }
+ }
+ if (arg_error) {
+ printf("%s: unknown argument %s\n",argv[0],argv[arg_error]);
+ sc = RTEMS_NOT_DEFINED;
+ }
+ return sc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_get_bufpool
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| get buffer pool information |
+| XXX: this should be coupled closer to the bdbuf.c module |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ struct bdbuf_pool **pool_base_pptr,
+ int *pool_cnt_ptr
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+#if 0
+ rtems_status_code pool_rc = RTEMS_SUCCESSFUL;
+ struct bdbuf_pool *curr_pool,*pool_base, *pool_top;
+ int pool_cnt;
+ int pool_probe_size;
+ /*
+ * get first buffer pool
+ * XXX: this is highly dependent on how pools are defined
+ * and maintained in bdbuf.c
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ /*
+ * try all possible pool sizes, get highest/lowest pool address
+ */
+ pool_base = NULL;
+ pool_top = NULL;
+ curr_pool = NULL;
+ for (pool_probe_size = 1;
+ pool_probe_size < (INT_MAX>>1) && (pool_rc == RTEMS_SUCCESSFUL);
+ pool_probe_size <<= 1) {
+ pool_rc = rtems_bdbuf_find_pool(pool_probe_size,&curr_pool);
+ if (pool_rc == RTEMS_SUCCESSFUL) {
+ if (pool_base > curr_pool) {
+ pool_base = curr_pool;
+ }
+ if (pool_top < curr_pool) {
+ pool_top = curr_pool;
+ }
+ }
+ }
+ if (pool_base == NULL) {
+ rc = RTEMS_UNSATISFIED;
+ }
+ else {
+ pool_cnt = (pool_top - pool_base) + 1;
+ }
+ }
+ if (rc == RTEMS_SUCCESSFUL) {
+ *pool_base_pptr = pool_base;
+ *pool_cnt_ptr = pool_cnt;
+ }
+#else
+ if (rc == RTEMS_SUCCESSFUL) {
+ *pool_base_pptr = rtems_bdbuf_ctx.pool;
+ *pool_cnt_ptr = rtems_bdbuf_ctx.npools;
+ }
+#endif
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_pool_header
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| print buffer pool information |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ int pool_idx,
+ bdbuf_pool *pool_ptr
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+
+ if (rc == RTEMS_SUCCESSFUL) {
+ printf("------------------------------------------------------------------------------\n");
+ printf(" pool #%03d: blksize=%5u nblks=%5u buf_mem=0x%08x bdbuf_mem=0x%08x\n",
+ pool_idx,
+ pool_ptr->blksize,
+ pool_ptr->nblks,
+ (uint32_t)(pool_ptr->mallocd_bufs),
+ (uint32_t)(pool_ptr->bdbufs));
+ printf("------------------------------------------------------------------------------\n");
+ }
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_show_bdbuf_get_bdbuf_info
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| get buffer pool information |
+| XXX: this should be coupled closer to the bdbuf.c module |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const bdbuf_buffer *the_bdbuf, /* this is the bdbuf structure */
+ int bdbuf_idx, /* index of bdbuf */
+ const bdbuf_pool *curr_pool, /* the pool this buffer belongs to */
+ show_bdbuf_bdbuf_info_t *bdbuf_info /* struct to store info of bdbuf */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+
+ /*
+ * determine the chain we are in
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_bdbuf_show_determine_chain_of_bdbuf(the_bdbuf,curr_pool,
+ &(bdbuf_info->in_chain));
+ if (rc != RTEMS_SUCCESSFUL) {
+ bdbuf_info->in_chain = bdbuf_chain_ident_none;
+ rc = RTEMS_SUCCESSFUL;
+ }
+ }
+
+ if (rc == RTEMS_SUCCESSFUL) {
+ bdbuf_info->index = bdbuf_idx;
+ bdbuf_info->dev = the_bdbuf->dev;
+ bdbuf_info->blknum = the_bdbuf->block;
+ bdbuf_info->status = the_bdbuf->status;
+ bdbuf_info->error = the_bdbuf->error;
+ bdbuf_info->modified = the_bdbuf->modified;
+ bdbuf_info->in_progress = the_bdbuf->in_progress;
+ bdbuf_info->actual = the_bdbuf->actual;
+ bdbuf_info->use_count = the_bdbuf->use_count;
+ bdbuf_info->sema = &(the_bdbuf->transfer_sema);
+ bdbuf_info->pool_id = the_bdbuf->pool;
+ }
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_show_bdbuf_match_filter
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| match bdbuf info with given filter |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const show_bdbuf_bdbuf_info_t *bdbuf_info, /* struct to store info of bdbuf */
+ const show_bdbuf_filter_t *filter,
+ boolean *is_match
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+ boolean unmatch = FALSE;
+
+ if (rc == RTEMS_SUCCESSFUL) {
+ if (filter->bdbuf_all) {
+ unmatch = FALSE;
+ }
+ else {
+ unmatch = ((filter->bdbuf_modified && !bdbuf_info->modified) ||
+ (filter->bdbuf_in_progress && !bdbuf_info->in_progress) ||
+ (filter->bdbuf_actual && !bdbuf_info->actual) ||
+ (filter->bdbuf_used && !(bdbuf_info->use_count > 0)));
+
+ }
+ *is_match = !unmatch;
+ }
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_show_bdbuf_print_wait_chain
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| list tasks waiting in "transfer_sema" chain |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ bdbuf_buffer *the_bdbuf /* this is the bdbuf structure */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+ Chain_Control *the_chain_head;
+ const Chain_Node *the_chain_node;
+ int thread_cnt = 0;
+ const Thread_Control *the_thread;
+ Objects_Id thread_id;
+ Objects_Name thread_name;
+ uint32_t thread_name_nonstring;
+ /*
+ * get head of (fifo) wait chain
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ the_chain_head = &(the_bdbuf->transfer_sema.Wait_queue.Queues.Fifo);
+ the_chain_node = the_chain_head->first;
+ }
+ /*
+ * walk through thread chain
+ */
+ while ((rc == RTEMS_SUCCESSFUL) &&
+ (the_chain_node != _Chain_Tail( the_chain_head ))) {
+ thread_cnt++;
+ the_thread = (const Thread_Control *)the_chain_node;
+
+ thread_id = the_thread->Object.id;
+ thread_name = the_thread->Object.name;
+ thread_name_nonstring = (uint32_t)thread_name;
+ printf("%20s %3d (0x%08x) %c%c%c%c\n",
+ ((thread_cnt == 1) ? "Threads waiting:" : ""),
+ thread_cnt,thread_id,
+ (thread_name_nonstring >> 24) & 0xff,
+ (thread_name_nonstring >> 16) & 0xff,
+ (thread_name_nonstring >> 8) & 0xff,
+ (thread_name_nonstring >> 0) & 0xff);
+
+ the_chain_node = the_chain_node->next;
+ }
+
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_show_bdbuf_print
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| print requested bdbuffer information |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const show_bdbuf_bdbuf_info_t *bdbuf_info, /* info of bdbuf */
+ show_bdbuf_selector_t * selector, /* selector, what to show */
+ boolean print_header /* TRUE: print header, not info */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+
+ /*
+ * 6 chars: print index of buffer
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ if (print_header) {
+ printf("INDEX ");
+ }
+ else {
+ printf("%5u ",bdbuf_info->index);
+ }
+ }
+ /*
+ * 3 chars: print info about the pool id of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_use_count))) {
+ if (print_header) {
+ printf("PL ");
+ }
+ else {
+ printf("%2u ",bdbuf_info->pool_id);
+ }
+ }
+
+ /*
+ * 4 chars: print info about chain (lru/free/mod) of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_node_chain))) {
+ if (print_header) {
+ printf("CHN ");
+ }
+ else {
+ printf("%3s ",
+ ((bdbuf_info->in_chain == bdbuf_chain_ident_free) ? "FRE"
+ : (bdbuf_info->in_chain == bdbuf_chain_ident_lru) ? "LRU"
+ : (bdbuf_info->in_chain == bdbuf_chain_ident_mod) ? "MOD"
+ : "???"));
+ }
+ }
+
+ /*
+ * 7 chars: print info about device of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_dev))) {
+ if (print_header) {
+ printf("DEVICE ");
+ }
+ else {
+ printf("%3u,%2u ",
+ ((bdbuf_info->dev == -1)
+ ? 0 : rtems_filesystem_dev_major_t(bdbuf_info->dev)),
+ ((bdbuf_info->dev == -1)
+ ? 0 : rtems_filesystem_dev_minor_t(bdbuf_info->dev)));
+ }
+ }
+
+ /*
+ * 7 chars: print info about block number of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_blocknum))) {
+ if (print_header) {
+ printf("BLOCK ");
+ }
+ else {
+ printf("%6u ",bdbuf_info->blknum);
+ }
+ }
+
+ /*
+ * 4 chars: print info about use count of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_use_count))) {
+ if (print_header) {
+ printf("USE ");
+ }
+ else {
+ printf("%3u ",bdbuf_info->use_count);
+ }
+ }
+
+ /*
+ * 4 chars: print info about state of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_state))) {
+ if (print_header) {
+ printf("STA ");
+ }
+ else {
+ printf("%c%c%c ",
+ (bdbuf_info->modified ? 'M' : '.'),
+ (bdbuf_info->in_progress ? 'P' : '.'),
+ (bdbuf_info->actual ? 'A' : '.'));
+ }
+ }
+
+ /*
+ * 42 chars: print info about error of this buffer
+ */
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ ((selector->show_all) ||
+ (selector->show_error))) {
+ if (print_header) {
+ printf("%20s:%-10s ","RTEMS STATUS","ERRNO");
+ }
+ else {
+ printf("%20s:%-10s ",
+ ((bdbuf_info->status == RTEMS_SUCCESSFUL)
+ ? "SUCCESSFUL" : rtems_status_text(bdbuf_info->status)),
+ ((bdbuf_info->status == RTEMS_SUCCESSFUL)
+ ? "" : strerror(bdbuf_info->error)));
+ }
+ }
+ /*
+ * FIXME: add info about waiting chain
+ */
+ printf("\n");
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+void rtems_bdbuf_show_fnc
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| list all bdbufs with their content |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ int argc,
+ char **argv,
+ rtems_monitor_command_arg_t* command_arg,
+ boolean verbose
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code rc = RTEMS_SUCCESSFUL;
+ show_bdbuf_filter_t filter;
+ show_bdbuf_selector_t selector;
+ show_bdbuf_bdbuf_info_t bdbuf_info;
+
+ bdbuf_pool *curr_pool,*pool_base;
+ int pool_cnt,pool_idx;
+ int bdbuf_idx;
+ boolean bdbuf_matches;
+ int matched_cnt,un_matched_cnt;
+
+ /*
+ * analyze command line options
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_bdbuf_show_getargs (argc,argv,
+ &filter,&selector);
+ }
+
+ /*
+ * get buffer pool information
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_bdbuf_show_get_bufpool(&pool_base,&pool_cnt);
+ if (rc != RTEMS_SUCCESSFUL) {
+ printf("%s: ERROR: no buffer pool found\n",argv[0]);
+ }
+ }
+ /*
+ * for all or selected buffer pool(s)
+ */
+ for (pool_idx = 0;
+ (rc == RTEMS_SUCCESSFUL) && (pool_idx < pool_cnt);
+ pool_idx++) {
+ if ((filter.pool_id < 0) ||
+ (filter.pool_id == pool_idx)) {
+ curr_pool = pool_base + pool_idx;
+ /*
+ * print pool header
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_bdbuf_show_pool_header(pool_idx,curr_pool);
+ }
+ if (rc == RTEMS_SUCCESSFUL) {
+ matched_cnt = 0;
+ un_matched_cnt = 0;
+ /*
+ * print header for bdbuf
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_show_bdbuf_print(NULL,&selector,
+ TRUE);
+ }
+ /*
+ * for all bdbufs in this pool
+ */
+ for (bdbuf_idx = 0;
+ ((rc == RTEMS_SUCCESSFUL) &&
+ (bdbuf_idx < curr_pool->nblks));
+ bdbuf_idx++) {
+ /*
+ * get infos about bdbuf
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_show_bdbuf_get_bdbuf_info
+ (&(curr_pool->bdbufs[bdbuf_idx]),
+ bdbuf_idx,
+ curr_pool,
+ &bdbuf_info);
+ }
+ /*
+ * check, if bdbuf matches selection criteria
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ rc = rtems_show_bdbuf_match_filter(&bdbuf_info,&filter,
+ &bdbuf_matches);
+ }
+ /*
+ * print info about bdbuf
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ if (bdbuf_matches) {
+ rc = rtems_show_bdbuf_print(&bdbuf_info,&selector,
+ FALSE);
+ if ((rc == RTEMS_SUCCESSFUL) &&
+ selector.show_sema) {
+ rc = rtems_show_bdbuf_print_wait_chain(&(curr_pool->bdbufs[bdbuf_idx]));
+ }
+ matched_cnt++;
+ }
+ else {
+ un_matched_cnt++;
+ }
+ }
+ }
+ /*
+ * print match statistics and footer
+ */
+ if (rc == RTEMS_SUCCESSFUL) {
+ printf("%d bdbufs printed, %d bdbufs suppressed\n",
+ matched_cnt,un_matched_cnt);
+ }
+ }
+ }
+ }
+}
+
+static rtems_monitor_command_entry_t rtems_show_bdbuf_cmds[] = {
+ {
+ "bdbuf_show",
+ "usage: bdbuf_show\n",
+ 0,
+ rtems_bdbuf_show_fnc,
+ { 0 },
+ 0
+ }
+};
+
+#ifndef ARRAY_CNT
+#define ARRAY_CNT(arr) (sizeof((arr))/sizeof((arr)[0]))
+#endif
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+rtems_status_code rtems_bdbuf_show_init
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| add command(s) to monitor |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ void /* none up to now */
+)
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| rtems_status_code |
+\*=========================================================================*/
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ int item;
+
+ for (item = 0;
+ (sc == RTEMS_SUCCESSFUL) && (item < ARRAY_CNT(rtems_show_bdbuf_cmds));
+ item++) {
+ if (0 == rtems_monitor_insert_cmd (&rtems_show_bdbuf_cmds[item])) {
+ sc = RTEMS_INVALID_NAME;
+ }
+ }
+ return sc;
+}
diff --git a/testsuites/samples/ChangeLog b/testsuites/samples/ChangeLog index 7f6724a5d7..c0193d014a 100644 --- a/testsuites/samples/ChangeLog +++ b/testsuites/samples/ChangeLog @@ -1,3 +1,7 @@ +2006-12-18 Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> + + * init.c: added stdout flushs after prompts + 2006-12-02 Ralf Corsépius <ralf.corsepius@rtems.org> * configure.ac: New BUG-REPORT address. diff --git a/testsuites/samples/fileio/init.c b/testsuites/samples/fileio/init.c index 88f63b113b..a62e3b0faf 100644 --- a/testsuites/samples/fileio/init.c +++ b/testsuites/samples/fileio/init.c @@ -129,6 +129,7 @@ void fileio_part_table_initialize(void) printf(" =========================\n"); fileio_print_free_heap(); printf(" Enter device to initialize ==>"); + fflush(stdout); fgets(devname,sizeof(devname)-1,stdin); while (devname[strlen(devname)-1] == '\n') { devname[strlen(devname)-1] = '\0'; @@ -175,6 +176,7 @@ void fileio_list_file(void) printf(" =========================\n"); fileio_print_free_heap(); printf(" Enter filename to list ==>"); + fflush(stdout); fgets(fname,sizeof(fname)-1,stdin); while (fname[strlen(fname)-1] == '\n') { fname[strlen(fname)-1] = '\0'; @@ -281,6 +283,7 @@ void fileio_write_file(void) */ if (!failed) { printf("Enter path/filename ==>"); + fflush(stdout); fgets(fname,sizeof(fname)-1,stdin); while (fname[strlen(fname)-1] == '\n') { fname[strlen(fname)-1] = '\0'; @@ -296,6 +299,7 @@ void fileio_write_file(void) if (!failed) { printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" "Enter filesize to write ==>"); + fflush(stdout); fgets(tmp_str,sizeof(tmp_str)-1,stdin); failed = fileio_str2size(tmp_str,&file_size); if (failed) { @@ -308,6 +312,7 @@ void fileio_write_file(void) if (!failed) { printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" "Enter block size to use for write calls ==>"); + fflush(stdout); fgets(tmp_str,sizeof(tmp_str)-1,stdin); failed = fileio_str2size(tmp_str,&buf_size); if (failed) { @@ -437,6 +442,7 @@ void fileio_read_file(void) */ if (!failed) { printf("Enter path/filename ==>"); + fflush(stdout); fgets(fname,sizeof(fname)-1,stdin); while (fname[strlen(fname)-1] == '\n') { fname[strlen(fname)-1] = '\0'; @@ -452,6 +458,7 @@ void fileio_read_file(void) if (!failed) { printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" "Enter block size to use for read calls ==>"); + fflush(stdout); fgets(tmp_str,sizeof(tmp_str)-1,stdin); failed = fileio_str2size(tmp_str,&buf_size); if (failed) { @@ -549,6 +556,7 @@ void fileio_menu (void) printf(" s -> start shell\n"); #endif printf(" Enter your selection ==>"); + fflush(stdout); inbuf[0] = '\0'; fgets(inbuf,sizeof(inbuf),stdin); |