Merge remote-tracking branch 'official/master' into auto-ci

This commit is contained in:
Rogerz Zhang committed 2013-04-01 19:06:22 +08:00
commit 489b3822f0
96 files changed
+4077 -1367

No files matched your search

+1
View File
@@ -10,3 +10,4 @@
*.idb
*.ilk
build
*~
+21 -20
View File
@@ -49,8 +49,6 @@ struct at91_mci {
rt_uint32_t current_status;
};
static struct at91_mci *at_mci;
/*
* Reset the controller and restore most of the state
*/
@@ -592,8 +590,9 @@ static void at91_mci_completed_command(struct at91_mci *mci, rt_uint32_t status)
/*
* Handle an interrupt
*/
static void at91_mci_irq(int irq)
static void at91_mci_irq(int irq, void *param)
{
struct at91_mci *mci = (struct at91_mci *)param;
rt_int32_t completed = 0;
rt_uint32_t int_status, int_mask;
@@ -635,13 +634,13 @@ static void at91_mci_irq(int irq)
if (int_status & AT91_MCI_TXBUFE)
{
mci_dbg("TX buffer empty\n");
at91_mci_handle_transmitted(at_mci);
at91_mci_handle_transmitted(mci);
}
if (int_status & AT91_MCI_ENDRX)
{
mci_dbg("ENDRX\n");
at91_mci_post_dma_read(at_mci);
at91_mci_post_dma_read(mci);
}
if (int_status & AT91_MCI_RXBUFF)
@@ -668,7 +667,7 @@ static void at91_mci_irq(int irq)
if (int_status & AT91_MCI_BLKE)
{
mci_dbg("Block transfer has ended\n");
if (at_mci->req->data && at_mci->req->data->blks > 1)
if (mci->req->data && mci->req->data->blks > 1)
{
/* multi block write : complete multi write
* command and send stop */
@@ -684,7 +683,7 @@ static void at91_mci_irq(int irq)
rt_mmcsd_signal_sdio_irq(host->mmc);*/
if (int_status & AT91_MCI_SDIOIRQB)
sdio_irq_wakeup(at_mci->host);
sdio_irq_wakeup(mci->host);
if (int_status & AT91_MCI_TXRDY)
mci_dbg("Ready to transmit\n");
@@ -695,7 +694,7 @@ static void at91_mci_irq(int irq)
if (int_status & AT91_MCI_CMDRDY)
{
mci_dbg("Command ready\n");
completed = at91_mci_handle_cmdrdy(at_mci);
completed = at91_mci_handle_cmdrdy(mci);
}
}
@@ -703,7 +702,7 @@ static void at91_mci_irq(int irq)
{
mci_dbg("Completed command\n");
at91_mci_write(AT91_MCI_IDR, 0xffffffff & ~(AT91_MCI_SDIOIRQA | AT91_MCI_SDIOIRQB));
at91_mci_completed_command(at_mci, int_status);
at91_mci_completed_command(mci, int_status);
}
else
at91_mci_write(AT91_MCI_IDR, int_status & ~(AT91_MCI_SDIOIRQA | AT91_MCI_SDIOIRQB));
@@ -791,7 +790,7 @@ static const struct rt_mmcsd_host_ops ops = {
at91_mci_enable_sdio_irq,
};
void at91_mci_detect(int irq)
void at91_mci_detect(int irq, void *param)
{
rt_kprintf("mmcsd gpio detected\n");
}
@@ -819,7 +818,7 @@ static void mci_gpio_init()
rt_int32_t at91_mci_init(void)
{
struct rt_mmcsd_host *host;
//struct at91_mci *mci;
struct at91_mci *mci;
host = mmcsd_alloc_host();
if (!host)
@@ -827,14 +826,14 @@ rt_int32_t at91_mci_init(void)
return -RT_ERROR;
}
at_mci = rt_malloc(sizeof(struct at91_mci));
if (!at_mci)
mci = rt_malloc(sizeof(struct at91_mci));
if (!mci)
{
rt_kprintf("alloc mci failed\n");
goto err;
}
rt_memset(at_mci, 0, sizeof(struct at91_mci));
rt_memset(mci, 0, sizeof(struct at91_mci));
host->ops = &ops;
host->freq_min = 375000;
@@ -846,7 +845,7 @@ rt_int32_t at91_mci_init(void)
host->max_blk_size = 512;
host->max_blk_count = 4096;
at_mci->host = host;
mci->host = host;
mci_gpio_init();
at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI); //enable MCI clock
@@ -855,14 +854,16 @@ rt_int32_t at91_mci_init(void)
at91_mci_enable();
/* instal interrupt */
rt_hw_interrupt_install(AT91SAM9260_ID_MCI, at91_mci_irq, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_MCI, at91_mci_irq,
(void *)mci, "MMC");
rt_hw_interrupt_umask(AT91SAM9260_ID_MCI);
rt_hw_interrupt_install(gpio_to_irq(AT91_PIN_PA7), at91_mci_detect, RT_NULL);
rt_hw_interrupt_install(gpio_to_irq(AT91_PIN_PA7),
at91_mci_detect, RT_NULL, "MMC_DETECT");
rt_hw_interrupt_umask(gpio_to_irq(AT91_PIN_PA7));
rt_timer_init(&at_mci->timer, "mci_timer",
rt_timer_init(&mci->timer, "mci_timer",
at91_timeout_timer,
at_mci,
mci,
RT_TICK_PER_SECOND,
RT_TIMER_FLAG_PERIODIC);
@@ -870,7 +871,7 @@ rt_int32_t at91_mci_init(void)
//rt_sem_init(&mci->sem_ack, "sd_ack", 0, RT_IPC_FLAG_FIFO);
host->private_data = at_mci;
host->private_data = mci;
mmcsd_change(host);
+17 -11
View File
@@ -92,9 +92,10 @@ struct rt_device uart4_device;
/**
* This function will handle serial
*/
void rt_serial_handler(int vector)
void rt_serial_handler(int vector, void *param)
{
int status;
struct rt_device *dev = (rt_device_t)param;
switch (vector)
{
@@ -105,7 +106,7 @@ void rt_serial_handler(int vector)
{
return;
}
rt_hw_serial_isr(&uart1_device);
rt_hw_serial_isr(dev);
break;
#endif
#ifdef RT_USING_UART1
@@ -115,7 +116,7 @@ void rt_serial_handler(int vector)
{
return;
}
rt_hw_serial_isr(&uart2_device);
rt_hw_serial_isr(dev);
break;
#endif
#ifdef RT_USING_UART2
@@ -125,7 +126,7 @@ void rt_serial_handler(int vector)
{
return;
}
rt_hw_serial_isr(&uart3_device);
rt_hw_serial_isr(dev);
break;
#endif
#ifdef RT_USING_UART3
@@ -135,7 +136,7 @@ void rt_serial_handler(int vector)
{
return;
}
rt_hw_serial_isr(&uart4_device);
rt_hw_serial_isr(dev);
break;
#endif
default: break;
@@ -176,7 +177,8 @@ void rt_hw_uart_init(void)
at91_sys_write(AT91_PIOB + PIO_PDR, (1<<4)|(1<<5));
uart_port_init(AT91SAM9260_BASE_US0);
/* install interrupt handler */
rt_hw_interrupt_install(AT91SAM9260_ID_US0, rt_serial_handler, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_US0, rt_serial_handler,
(void *)&uart1_device, "UART0");
rt_hw_interrupt_umask(AT91SAM9260_ID_US0);
#endif
#ifdef RT_USING_UART1
@@ -188,7 +190,8 @@ void rt_hw_uart_init(void)
at91_sys_write(AT91_PIOB + PIO_PDR, (1<<6)|(1<<7));
uart_port_init(AT91SAM9260_BASE_US1);
/* install interrupt handler */
rt_hw_interrupt_install(AT91SAM9260_ID_US1, rt_serial_handler, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_US1, rt_serial_handler,
(void *)&uart2_device, "UART1");
rt_hw_interrupt_umask(AT91SAM9260_ID_US1);
#endif
#ifdef RT_USING_UART2
@@ -200,7 +203,8 @@ void rt_hw_uart_init(void)
at91_sys_write(AT91_PIOB + PIO_PDR, (1<<8)|(1<<9));
uart_port_init(AT91SAM9260_BASE_US2);
/* install interrupt handler */
rt_hw_interrupt_install(AT91SAM9260_ID_US2, rt_serial_handler, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_US2, rt_serial_handler,
(void *)&uart3_device, "UART2");
rt_hw_interrupt_umask(AT91SAM9260_ID_US2);
#endif
#ifdef RT_USING_UART3
@@ -212,7 +216,8 @@ void rt_hw_uart_init(void)
at91_sys_write(AT91_PIOB + PIO_PDR, (1<<10)|(1<<11));
uart_port_init(AT91SAM9260_BASE_US3);
/* install interrupt handler */
rt_hw_interrupt_install(AT91SAM9260_ID_US3, rt_serial_handler, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_US3, rt_serial_handler,
(void *)&uart4_device, "UART3");
rt_hw_interrupt_umask(AT91SAM9260_ID_US3);
#endif
@@ -246,7 +251,7 @@ static rt_uint32_t pit_cnt; /* access only w/system irq blocked */
/**
* This function will handle rtos timer
*/
void rt_timer_handler(int vector)
void rt_timer_handler(int vector, void *param)
{
#ifdef RT_USING_DBGU
if (at91_sys_read(AT91_DBGU + AT91_US_CSR) & 0x1) {
@@ -309,7 +314,8 @@ static void at91sam926x_pit_init(void)
at91sam926x_pit_init();
/* install interrupt handler */
rt_hw_interrupt_install(AT91_ID_SYS, rt_timer_handler, RT_NULL);
rt_hw_interrupt_install(AT91_ID_SYS, rt_timer_handler,
RT_NULL, "system");
rt_hw_interrupt_umask(AT91_ID_SYS);
}
+16 -6
View File
@@ -103,9 +103,9 @@ static void udelay(rt_uint32_t us)
for (len = 0; len < 10; len++ );
}
static void rt_macb_isr(int irq)
static void rt_macb_isr(int irq, void *param)
{
struct rt_macb_eth *macb = &macb_device;
struct rt_macb_eth *macb = (struct rt_macb_eth *)param;
rt_device_t dev = &(macb->parent.parent);
rt_uint32_t status, rsr, tsr;
@@ -150,7 +150,7 @@ static void rt_macb_isr(int irq)
}
static void macb_mdio_write(struct rt_macb_eth *macb, rt_uint8_t reg, rt_uint16_t value)
static int macb_mdio_write(struct rt_macb_eth *macb, rt_uint8_t reg, rt_uint16_t value)
{
unsigned long netctl;
unsigned long netstat;
@@ -179,7 +179,7 @@ static void macb_mdio_write(struct rt_macb_eth *macb, rt_uint8_t reg, rt_uint16_
rt_sem_release(&macb->mdio_bus_lock);
}
static rt_uint16_t macb_mdio_read(struct rt_macb_eth *macb, rt_uint8_t reg)
static int macb_mdio_read(struct rt_macb_eth *macb, rt_uint8_t reg)
{
unsigned long netctl;
unsigned long netstat;
@@ -298,12 +298,21 @@ void macb_update_link(void *param)
{
struct rt_macb_eth *macb = (struct rt_macb_eth *)param;
rt_device_t dev = &macb->parent.parent;
rt_uint32_t status, status_change = 0;
int status, status_change = 0;
rt_uint32_t link;
rt_uint32_t media;
rt_uint16_t adv, lpa;
/* Do a fake read */
status = macb_mdio_read(macb, MII_BMSR);
if (status < 0)
return;
/* Read link and autonegotiation status */
status = macb_mdio_read(macb, MII_BMSR);
if (status < 0)
return;
if ((status & BMSR_LSTATUS) == 0)
link = 0;
else
@@ -403,7 +412,8 @@ static rt_err_t rt_macb_init(rt_device_t dev)
| MACB_BIT(HRESP)));
/* instal interrupt */
rt_hw_interrupt_install(AT91SAM9260_ID_EMAC, rt_macb_isr, RT_NULL);
rt_hw_interrupt_install(AT91SAM9260_ID_EMAC, rt_macb_isr,
(void *)macb, "emac");
rt_hw_interrupt_umask(AT91SAM9260_ID_EMAC);
rt_timer_init(&macb->timer, "link_timer",
+2
View File
@@ -22,6 +22,8 @@
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_INTERRUPT_INFO
/* Using Hook */
#define RT_USING_HOOK
+1
View File
@@ -18,6 +18,7 @@
/* Thread Debug */
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_INTERRUPT_INFO
/* Using Hook */
#define RT_USING_HOOK
+3 -3
View File
@@ -25,7 +25,7 @@
/* UART interrupt enable register value */
#define UARTIER_IME (1 << 3)
#define UARTIER_ILE (1 << 2)
#define UARTIER_ILE (1 << 2)
#define UARTIER_ITXE (1 << 1)
#define UARTIER_IRXE (1 << 0)
@@ -59,7 +59,7 @@ struct rt_uart_soc3210
rt_uint8_t rx_buffer[RT_UART_RX_BUFFER_SIZE];
}uart_device;
static void rt_uart_irqhandler(int irqno)
static void rt_uart_irqhandler(int irqno, void *param)
{
rt_ubase_t level;
rt_uint8_t isr;
@@ -142,7 +142,7 @@ static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
UART_IER(uart->hw_base) |= UARTIER_IRXE;
/* install interrupt */
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, RT_NULL);
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, RT_NULL, "UART");
rt_hw_interrupt_umask(uart->irq);
}
return RT_EOK;
+3 -30
View File
@@ -27,7 +27,7 @@
/**
* This is the timer interrupt service routine.
*/
void rt_hw_timer_handler()
void rt_hw_timer_handler(int vector, void* param)
{
/* increase a OS tick */
rt_tick_increase();
@@ -39,7 +39,7 @@ void rt_hw_timer_handler()
/**
* This function will initial OS timer
*/
void rt_hw_timer_init()
void rt_hw_timer_init(void)
{
rt_uint32_t val;
@@ -52,33 +52,6 @@ void rt_hw_timer_init()
/* clear counter */
OST_CNT = 0;
#if 0
switch (RTC_DIV)
{
case 1:
val = OST_TCSR_PRESCALE1;
break;
case 4:
val = OST_TCSR_PRESCALE4;
break;
case 16:
val = OST_TCSR_PRESCALE16;
break;
case 64:
val = OST_TCSR_PRESCALE64;
break;
case 256:
val = OST_TCSR_PRESCALE256;
break;
case 1024:
val = OST_TCSR_PRESCALE1024;
break;
default:
val = OST_TCSR_PRESCALE4;
break;
}
#endif
#ifdef RTC_SRC_EXTAL
OST_CSR = (val | OST_TCSR_EXT_EN);
#else
@@ -89,7 +62,7 @@ void rt_hw_timer_init()
TCU_TMCR = TCU_TMCR_OSTMCL;
TCU_TESR = TCU_TESR_OSTST;
rt_hw_interrupt_install(IRQ_TCU0, rt_hw_timer_handler, RT_NULL);
rt_hw_interrupt_install(IRQ_TCU0, rt_hw_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask (IRQ_TCU0);
}
+1
View File
@@ -18,6 +18,7 @@
/* Thread Debug */
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_INTERRUPT_INFO
/* Using Hook */
#define RT_USING_HOOK
+4 -4
View File
@@ -10,7 +10,7 @@
/*@{*/
#if defined(RT_USING_UART) && defined(RT_USING_DEVICE)
#define UART_BAUDRATE 115200
#define UART_BAUDRATE 57600
#define DEV_CLK 12000000
/*
@@ -129,10 +129,10 @@ struct rt_uart_jz
rt_uint8_t rx_buffer[RT_UART_RX_BUFFER_SIZE];
}uart_device;
static void rt_uart_irqhandler(int irqno)
static void rt_uart_irqhandler(int vector, void* param)
{
rt_ubase_t level, isr;
struct rt_uart_jz* uart = &uart_device;
struct rt_uart_jz* uart = param;
/* read interrupt status and clear it */
isr = UART_ISR(uart->hw_base);
@@ -212,7 +212,7 @@ static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
UART_IER(uart->hw_base) |= (UARTIER_RIE | UARTIER_RTIE);
/* install interrupt */
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, RT_NULL);
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, uart, "uart");
rt_hw_interrupt_umask(uart->irq);
}
return RT_EOK;
File diff suppressed because it is too large. Load diff
-133
View File
@@ -1,133 +0,0 @@
/*
* linker script for LPC1788 (512kB Flash, 48kB + 48kB SRAM ) with GNU ld
* yiyue.fang 2012-04-14
*/
/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000
}
ENTRY(Reset_Handler)
_system_stack_size = 0x200;
SECTIONS
{
.text :
{
. = ALIGN(4);
KEEP(*(.interrupt_vector)) /* Startup code */
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
. = ALIGN(4);
_etext = .;
} > CODE = 0
/* .ARM.exidx is sorted, so has to go in its own output section. */
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
/* This is used by the startup in order to initialize the .data secion */
_sidata = .;
} > CODE
__exidx_end = .;
/* .data section which is used for initialized data */
.data : AT (_sidata)
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = . ;
} >DATA
.stack :
{
. = . + _system_stack_size;
. = ALIGN(4);
_estack = .;
} >DATA
__bss_start = .;
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
*(.bss.init)
} > DATA
__bss_end = .;
_end = .;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
-15
View File
@@ -1,15 +0,0 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x00000000 0x00080000 { ; load region size_region
ER_IROM1 0x00000000 0x00080000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x10000000 0x00010000 { ; RW data
.ANY (+RW +ZI)
}
}
+6 -6
View File
@@ -70,12 +70,12 @@ SECTIONS
_edata = . ;
} >DATA
.stack :
{
. = . + _system_stack_size;
. = ALIGN(4);
_estack = .;
} >DATA
.stack :
{
. = . + _system_stack_size;
. = ALIGN(4);
_estack = .;
} >DATA
__bss_start = .;
.bss :
+7 -7
View File
@@ -27,7 +27,7 @@
* This is the timer interrupt service routine.
* @param vector the irq number for timer
*/
void rt_hw_timer_handler(int vector)
void rt_hw_timer_handler(int vector, void *param)
{
rt_tick_increase();
@@ -53,10 +53,10 @@ void rt_hw_console_output(const char* str)
while (!(U0LSR & 0x20));
U0THR = '\r';
}
while (!(U0LSR & 0x20));
U0THR = *str;
str ++;
}
}
@@ -82,11 +82,11 @@ void rt_hw_console_init()
/**
* This function will initial sam7x256 board.
*/
void rt_hw_board_init()
void rt_hw_board_init(void)
{
/* console init */
rt_hw_console_init();
/* prescaler = 0*/
T0PR = 0;
T0PC = 0;
@@ -94,12 +94,12 @@ void rt_hw_board_init()
/* reset and enable MR0 interrupt */
T0MCR = 0x3;
T0MR0 = PCLK / RT_TICK_PER_SECOND;
/* enable timer 0 */
T0TCR = 1;
/* install timer handler */
rt_hw_interrupt_install(TIMER0_INT, rt_hw_timer_handler, RT_NULL);
rt_hw_interrupt_install(TIMER0_INT, rt_hw_timer_handler, RT_NULL, "TIMER0");
rt_hw_interrupt_umask(TIMER0_INT);
}
+27 -23
View File
@@ -69,7 +69,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
UNUSED rt_uint32_t iir;
RT_ASSERT(lpc_serial != RT_NULL)
if (UART_LSR(lpc_serial->hw_base) & 0x01)
{
rt_base_t level;
@@ -80,12 +80,12 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
level = rt_hw_interrupt_disable();
/* read character */
lpc_serial->rx_buffer[lpc_serial->save_index] =
lpc_serial->rx_buffer[lpc_serial->save_index] =
UART_RBR(lpc_serial->hw_base);
lpc_serial->save_index ++;
if (lpc_serial->save_index >= RT_UART_RX_BUFFER_SIZE)
lpc_serial->save_index = 0;
/* if the next position is read index, discard this 'read char' */
if (lpc_serial->save_index == lpc_serial->read_index)
{
@@ -113,7 +113,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
}
#ifdef RT_USING_UART1
void rt_hw_uart_isr_1(int irqno)
void rt_hw_uart_isr_1(int irqno, void *param)
{
/* get lpc serial device */
rt_hw_uart_isr(&serial1);
@@ -121,7 +121,7 @@ void rt_hw_uart_isr_1(int irqno)
#endif
#ifdef RT_USING_UART2
void rt_hw_uart_isr_2(int irqno)
void rt_hw_uart_isr_2(int irqno, void *param)
{
/* get lpc serial device */
rt_hw_uart_isr(&serial2);
@@ -153,13 +153,15 @@ static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
if (lpc_serial->irqno == UART0_INT)
{
#ifdef RT_USING_UART1
rt_hw_interrupt_install(lpc_serial->irqno, rt_hw_uart_isr_1, RT_NULL);
rt_hw_interrupt_install(lpc_serial->irqno,
rt_hw_uart_isr_1, &serial1, "UART1");
#endif
}
else
{
#ifdef RT_USING_UART2
rt_hw_interrupt_install(lpc_serial->irqno, rt_hw_uart_isr_2, RT_NULL);
rt_hw_interrupt_install(lpc_serial->irqno,
rt_hw_uart_isr_2, &serial2, "UART2");
#endif
}
@@ -173,7 +175,7 @@ static rt_err_t rt_serial_close(rt_device_t dev)
{
struct rt_lpcserial* lpc_serial;
lpc_serial = (struct rt_lpcserial*) dev;
RT_ASSERT(lpc_serial != RT_NULL);
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
@@ -244,7 +246,7 @@ static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_
{
/* Read Character */
*ptr = UART_RBR(lpc_serial->hw_base);
ptr ++;
size --;
}
@@ -271,7 +273,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
/* polling write */
ptr = (char *)buffer;
if (dev->flag & RT_DEVICE_FLAG_STREAM)
{
/* stream mode */
@@ -285,7 +287,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
while (!(UART_LSR(lpc_serial->hw_base) & 0x20));
UART_THR(lpc_serial->hw_base) = *ptr;
ptr ++;
size --;
}
@@ -296,37 +298,37 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
{
while (!(UART_LSR(lpc_serial->hw_base) & 0x20));
UART_THR(lpc_serial->hw_base) = *ptr;
ptr ++;
size --;
}
}
return (rt_size_t) ptr - (rt_size_t) buffer;
}
void rt_hw_serial_init(void)
{
struct rt_lpcserial* lpc_serial;
#ifdef RT_USING_UART1
lpc_serial = &serial1;
lpc_serial->parent.type = RT_Device_Class_Char;
lpc_serial->hw_base = 0xE000C000;
lpc_serial->baudrate = 115200;
lpc_serial->irqno = UART0_INT;
rt_memset(lpc_serial->rx_buffer, 0, sizeof(lpc_serial->rx_buffer));
lpc_serial->read_index = lpc_serial->save_index = 0;
/* Enable UART0 RxD and TxD pins */
PINSEL0 |= 0x05;
PINSEL0 |= 0x05;
/* 8 bits, no Parity, 1 Stop bit */
UART_LCR(lpc_serial->hw_base) = 0x83;
/* Setup Baudrate */
UART_DLL(lpc_serial->hw_base) = (PCLK/16/lpc_serial->baudrate) & 0xFF;
UART_DLM(lpc_serial->hw_base) = ((PCLK/16/lpc_serial->baudrate) >> 8) & 0xFF;
@@ -334,6 +336,7 @@ void rt_hw_serial_init(void)
/* DLAB = 0 */
UART_LCR(lpc_serial->hw_base) = 0x03;
lpc_serial->parent.type = RT_Device_Class_Char;
lpc_serial->parent.init = rt_serial_init;
lpc_serial->parent.open = rt_serial_open;
lpc_serial->parent.close = rt_serial_close;
@@ -342,13 +345,13 @@ void rt_hw_serial_init(void)
lpc_serial->parent.control = rt_serial_control;
lpc_serial->parent.user_data = RT_NULL;
rt_device_register(&lpc_serial->parent,
rt_device_register(&lpc_serial->parent,
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
#endif
#ifdef RT_USING_UART2
lpc_serial = &serial2;
lpc_serial->parent.type = RT_Device_Class_Char;
lpc_serial->hw_base = 0xE0010000;
@@ -363,7 +366,7 @@ void rt_hw_serial_init(void)
/* 8 bits, no Parity, 1 Stop bit */
UART_LCR(lpc_serial->hw_base) = 0x83;
/* Setup Baudrate */
UART_DLL(lpc_serial->hw_base) = (PCLK/16/lpc_serial->baudrate) & 0xFF;
UART_DLM(lpc_serial->hw_base) = ((PCLK/16/lpc_serial->baudrate) >> 8) & 0xFF;
@@ -371,6 +374,7 @@ void rt_hw_serial_init(void)
/* DLAB = 0 */
UART_LCR(lpc_serial->hw_base) = 0x03;
lpc_serial->parent.type = RT_Device_Class_Char;
lpc_serial->parent.init = rt_serial_init;
lpc_serial->parent.open = rt_serial_open;
lpc_serial->parent.close = rt_serial_close;
@@ -379,7 +383,7 @@ void rt_hw_serial_init(void)
lpc_serial->parent.control = rt_serial_control;
lpc_serial->parent.user_data = RT_NULL;
rt_device_register(&lpc_serial->parent,
rt_device_register(&lpc_serial->parent,
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
#endif
}
+3 -3
View File
@@ -27,7 +27,7 @@ extern void rt_hw_serial_init(void);
*/
/*@{*/
void rt_timer_handler(int vector)
void rt_timer_handler(int vector, void* param)
{
T0IR |= 0x01; /* clear interrupt flag */
rt_tick_increase();
@@ -37,7 +37,7 @@ void rt_timer_handler(int vector)
/**
* This function will init LPC2478 board
*/
void rt_hw_board_init()
void rt_hw_board_init(void)
{
#if defined(RT_USING_DEVICE) && defined(RT_USING_UART1)
rt_hw_serial_init();
@@ -49,7 +49,7 @@ void rt_hw_board_init()
T0MCR = 0x03;
T0MR0 = (DATA_COUNT);
rt_hw_interrupt_install(TIMER0_INT, rt_timer_handler, RT_NULL);
rt_hw_interrupt_install(TIMER0_INT, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(TIMER0_INT);
T0TCR = 0x01; //enable timer0 counter
+4 -29
View File
@@ -64,9 +64,10 @@ void rt_hw_serial_init(void);
#define U0PINS 0x00000005
void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
void rt_hw_uart_isr(int irqno, void *param)
{
UNUSED rt_uint32_t iir;
struct rt_lpcserial* lpc_serial = (struct rt_lpcserial*)param;
RT_ASSERT(lpc_serial != RT_NULL)
@@ -112,21 +113,6 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
VICVectAddr = 0;
}
#ifdef RT_USING_UART1
void rt_hw_uart_isr_1(int irqno)
{
/* get lpc serial device */
rt_hw_uart_isr(&serial1);
}
#endif
#ifdef RT_USING_UART2
void rt_hw_uart_isr_2(int irqno)
{
/* get lpc serial device */
rt_hw_uart_isr(&serial2);
}
#endif
/**
* @addtogroup LPC214x
@@ -150,19 +136,8 @@ static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
UART_IER(lpc_serial->hw_base) = 0x01;
/* install ISR */
if (lpc_serial->irqno == UART0_INT)
{
#ifdef RT_USING_UART1
rt_hw_interrupt_install(lpc_serial->irqno, rt_hw_uart_isr_1, RT_NULL);
#endif
}
else
{
#ifdef RT_USING_UART2
rt_hw_interrupt_install(lpc_serial->irqno, rt_hw_uart_isr_2, RT_NULL);
#endif
}
rt_hw_interrupt_install(lpc_serial->irqno,
rt_hw_uart_isr, lpc_serial, RT_NULL);
rt_hw_interrupt_umask(lpc_serial->irqno);
}
+2 -2
View File
@@ -37,7 +37,7 @@ struct rt_uart_ls1b
rt_uint8_t rx_buffer[RT_UART_RX_BUFFER_SIZE];
}uart_device;
static void rt_uart_irqhandler(int irqno)
static void rt_uart_irqhandler(int irqno, void *param)
{
rt_ubase_t level;
rt_uint8_t isr;
@@ -121,7 +121,7 @@ static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
UART_IER(uart->hw_base) |= UARTIER_IRXE;
/* install interrupt */
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, RT_NULL);
rt_hw_interrupt_install(uart->irq, rt_uart_irqhandler, RT_NULL, "UART");
rt_hw_interrupt_umask(uart->irq);
}
return RT_EOK;
+2
View File
@@ -21,6 +21,8 @@
// #define RT_THREAD_DEBUG
// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" />
#define RT_USING_OVERFLOW_CHECK
// <bool name="RT_USING_INTERRUPT_INFO" description="Show more interrupt description" default="true" />
#define RT_USING_INTERRUPT_INFO
// </section>
// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" />
+11 -11
View File
@@ -58,7 +58,7 @@ struct rt_device uart2_device;
/**
* This function will handle rtos timer
*/
static void rt_timer_handler(int vector)
static void rt_timer_handler(int vector, void *param)
{
rt_tick_increase();
}
@@ -66,7 +66,7 @@ static void rt_timer_handler(int vector)
/**
* This function will handle serial
*/
static void rt_serial0_handler(int vector)
static void rt_serial0_handler(int vector, void *param)
{
INTSUBMSK |= (BIT_SUB_RXD0);
@@ -81,7 +81,7 @@ static void rt_serial0_handler(int vector)
/**
* This function will handle serial
*/
static void rt_serial2_handler(int vector)
static void rt_serial2_handler(int vector, void *param)
{
INTSUBMSK |= (BIT_SUB_RXD2);
@@ -133,7 +133,7 @@ static void rt_hw_uart_init(void)
uart2.uart_device->ucon = 0x245;
/* Set uart0 bps */
uart2.uart_device->ubrd = (rt_int32_t)(PCLK / (BPS * 16)) - 1;
for (i = 0; i < 100; i++);
/* install uart0 isr */
@@ -141,18 +141,18 @@ static void rt_hw_uart_init(void)
/* install uart2 isr */
INTSUBMSK &= ~(BIT_SUB_RXD2);
rt_hw_interrupt_install(INTUART0, rt_serial0_handler, RT_NULL);
rt_hw_interrupt_install(INTUART0, rt_serial0_handler, RT_NULL, "UART0");
rt_hw_interrupt_umask(INTUART0);
rt_hw_interrupt_install(INTUART2, rt_serial2_handler, RT_NULL);
rt_hw_interrupt_umask(INTUART2);
rt_hw_interrupt_install(INTUART2, rt_serial2_handler, RT_NULL, "UART2");
rt_hw_interrupt_umask(INTUART2);
}
/**
* This function will init timer4 for system ticks
*/
static void rt_hw_timer_init()
static void rt_hw_timer_init(void)
{
/* timer4, pre = 15+1 */
TCFG0 &= 0xffff00ff;
@@ -165,7 +165,7 @@ static void rt_hw_timer_init()
/* manual update */
TCON = TCON & (~(0x0f<<20)) | (0x02<<20);
/* install interrupt handler */
rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL);
rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(INTTIMER4);
/* start timer4, reload */
@@ -175,7 +175,7 @@ static void rt_hw_timer_init()
/**
* This function will init s3ceb2410 board
*/
void rt_hw_board_init()
void rt_hw_board_init(void)
{
/* initialize the system clock */
rt_hw_clock_init();
+2 -2
View File
@@ -572,7 +572,7 @@ __error_retry:
#define B4_Tacp 0x0
#define B4_PMC 0x0
void INTEINT4_7_handler(int irqno)
void INTEINT4_7_handler(int irqno, void *param)
{
rt_uint32_t eint_pend;
@@ -637,7 +637,7 @@ void rt_hw_dm9000_init()
eth_device_init(&(dm9000_device.parent), "e0");
/* instal interrupt */
rt_hw_interrupt_install(INTEINT4_7, INTEINT4_7_handler, RT_NULL);
rt_hw_interrupt_install(INTEINT4_7, INTEINT4_7_handler, RT_NULL, "EINT4_7");
rt_hw_interrupt_umask(INTEINT4_7);
}
+2
View File
@@ -22,6 +22,8 @@
// #define RT_THREAD_DEBUG
// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" />
#define RT_USING_OVERFLOW_CHECK
// <bool name="RT_USING_INTERRUPT_INFO" description="Show more interrupt description" default="true" />
#define RT_USING_INTERRUPT_INFO
// </section>
// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" />
+6 -5
View File
@@ -34,7 +34,7 @@ struct serial_device uart0 =
/**
* This function will handle rtos timer
*/
void rt_timer_handler(int vector)
void rt_timer_handler(int vector, void *param)
{
rt_uint32_t clear_int;
rt_tick_increase();
@@ -47,7 +47,7 @@ void rt_timer_handler(int vector)
/**
* This function will handle serial
*/
void rt_serial_handler(int vector)
void rt_serial_handler(int vector, void *param)
{
//rt_kprintf("in rt_serial_handler\n");
rt_int32_t stat = *(RP)UART0_IIR ;
@@ -78,16 +78,17 @@ static void rt_hw_board_led_init(void)
*(RP)GPIO_PORTE_DATA &= ~0x38; /* low */
}
/**
* This function will init timer4 for system ticks
*/
void rt_hw_timer_init(void)
void rt_hw_timer_init(void)
{
/*Set timer1*/
*(RP)TIMER_T1LCR = 880000;
*(RP)TIMER_T1CR = 0x06;
rt_hw_interrupt_install(INTSRC_TIMER1, rt_timer_handler, RT_NULL);
rt_hw_interrupt_install(INTSRC_TIMER1, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(INTSRC_TIMER1);
/*Enable timer1*/
@@ -119,7 +120,7 @@ void rt_hw_uart_init(void)
/*Disable tx interrupt*/
*(RP)(UART0_IER) &= ~(0x1<<1);
rt_hw_interrupt_install(INTSRC_UART0, rt_serial_handler, RT_NULL);
rt_hw_interrupt_install(INTSRC_UART0, rt_serial_handler, RT_NULL, "UART0");
rt_hw_interrupt_umask(INTSRC_UART0);
/* register uart0 */
rt_hw_serial_register(&uart0_device, "uart0",
+3 -3
View File
@@ -81,7 +81,7 @@ struct rt_dm9161_eth
static struct rt_dm9161_eth dm9161_device;
static struct rt_semaphore sem_ack, sem_lock;
void rt_dm9161_isr(int irqno);
void rt_dm9161_isr(int irqno, void *param);
static void udelay(unsigned long ns)
{
@@ -201,7 +201,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
}
/* interrupt service routine */
void rt_dm9161_isr(int irqno)
void rt_dm9161_isr(int irqno, void *param)
{
unsigned long intstatus;
rt_uint32_t address;
@@ -469,7 +469,7 @@ static rt_err_t rt_dm9161_open(rt_device_t dev, rt_uint16_t oflag)
*(volatile unsigned long*)GPIO_PORTA_INTRCLR |= 0x0080; //清除中断
*(volatile unsigned long*)GPIO_PORTA_INTRCLR = 0x0000; //清除中断
rt_hw_interrupt_install(INTSRC_MAC, rt_dm9161_isr, RT_NULL);
rt_hw_interrupt_install(INTSRC_MAC, rt_dm9161_isr, RT_NULL, "EMAC");
enable_irq(INTSRC_EXINT7);
+1
View File
@@ -20,6 +20,7 @@
/* #define RT_THREAD_DEBUG */
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_INTERRUPT_INFO
/* Using Hook */
#define RT_USING_HOOK
+2 -2
View File
@@ -31,14 +31,14 @@ Options 1,0,0 // Target 'RT-Thread_Mini4020'
EnvReg ()
OrgReg ()
TgStat=16
OutDir (.\)
OutDir (.\build\)
OutName (rtthread-mini4020)
GenApp=1
GenLib=0
GenHex=0
Debug=1
Browse=0
LstDir (.\)
LstDir (.\build\)
HexSel=1
MG32K=0
TGMORE=0
+1 -1
View File
@@ -97,7 +97,7 @@ void rtthread_startup(void)
#elif __ICCARM__
rt_system_heap_init(__segment_end("HEAP"), (void*)0x00210000);
#else
rt_system_heap_init(&__bss_end, 0x00210000);
rt_system_heap_init(&__bss_end, (void*)0x00210000);
#endif
#endif
+3 -3
View File
@@ -33,7 +33,7 @@ static void rt_hw_board_led_init(void);
* This is the timer interrupt service routine.
* @param vector the irq number for timer
*/
void rt_hw_timer_handler(int vector)
void rt_hw_timer_handler(int vector, void* param)
{
if (AT91C_BASE_PITC->PITC_PISR & 0x01)
{
@@ -154,7 +154,7 @@ static void rt_hw_console_init()
/**
* This function will initial sam7x board.
*/
void rt_hw_board_init()
void rt_hw_board_init(void)
{
extern void rt_serial_init(void);
@@ -168,7 +168,7 @@ void rt_hw_board_init()
AT91C_BASE_PITC->PITC_PIMR = (1 << 25) | (1 << 24) | PIV;
/* install timer handler */
rt_hw_interrupt_install(AT91C_ID_SYS, rt_hw_timer_handler, RT_NULL);
rt_hw_interrupt_install(AT91C_ID_SYS, rt_hw_timer_handler, RT_NULL, "tick");
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_SYS] = 0;
rt_hw_interrupt_umask(AT91C_ID_SYS);
}
+2 -2
View File
@@ -120,7 +120,7 @@ rt_inline void sam7xether_reset_tx_desc(void)
/* interrupt service routing */
static void sam7xether_isr(int irq)
static void sam7xether_isr(int irq, void* param)
{
/* Variable definitions can be made now. */
volatile rt_uint32_t isr, rsr;
@@ -377,7 +377,7 @@ rt_err_t sam7xether_init(rt_device_t dev)
AT91C_BASE_EMAC->EMAC_IER = AT91C_EMAC_RCOMP | AT91C_EMAC_TCOMP;
/* setup interrupt */
rt_hw_interrupt_install(AT91C_ID_EMAC, sam7xether_isr, RT_NULL);
rt_hw_interrupt_install(AT91C_ID_EMAC, sam7xether_isr, RT_NULL, "emac");
*(volatile unsigned int*)(0xFFFFF000 + AT91C_ID_EMAC * 4) = AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 5;
// AT91C_AIC_SMR(AT91C_ID_EMAC) = AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 5;
rt_hw_interrupt_umask(AT91C_ID_EMAC);
+3 -18
View File
@@ -76,27 +76,12 @@ struct rt_at91serial serial1;
struct rt_at91serial serial2;
#endif
static void rt_hw_serial_isr(int irqno)
static void rt_hw_serial_isr(int irqno, void* param)
{
rt_base_t level;
struct rt_device* device;
struct rt_at91serial* serial = RT_NULL;
struct rt_at91serial* serial = (struct rt_at91serial*)param;
#ifdef RT_USING_UART1
if (irqno == AT91C_ID_US0)
{
/* serial 1 */
serial = &serial1;
}
#endif
#ifdef RT_USING_UART2
if (irqno == AT91C_ID_US1)
{
/* serial 2 */
serial = &serial2;
}
#endif
RT_ASSERT(serial != RT_NULL);
/* get generic device object */
@@ -202,7 +187,7 @@ static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
//serial->hw_base->US_IMR |= 1 << 0; /* umask RxReady interrupt */
/* install UART handler */
rt_hw_interrupt_install(serial->peripheral_id, rt_hw_serial_isr, RT_NULL);
rt_hw_interrupt_install(serial->peripheral_id, rt_hw_serial_isr, serial, "uart");
// SAM7X Datasheet 30.5.3:
// It is notrecommended to use the USART interrupt line in edge sensitive mode
//AT91C_AIC_SMR(serial->peripheral_id) = 5 | (0x01 << 5);
-2
View File
@@ -184,7 +184,6 @@ static void *sdl_loop(void *lpParam)
switch (event.type)
{
case SDL_MOUSEMOTION:
#if 0
{
struct rtgui_event_mouse emouse;
emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
@@ -200,7 +199,6 @@ static void *sdl_loop(void *lpParam)
/* send event to server */
rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
}
#endif
break;
case SDL_MOUSEBUTTONDOWN:
+6
View File
@@ -304,6 +304,9 @@ char *dfs_normalize_path(const char *directory, const char *filename)
{
fullpath = rt_malloc(strlen(directory) + strlen(filename) + 2);
if (fullpath == RT_NULL)
return RT_NULL;
/* join path and file name */
rt_snprintf(fullpath, strlen(directory) + strlen(filename) + 2,
"%s/%s", directory, filename);
@@ -311,6 +314,9 @@ char *dfs_normalize_path(const char *directory, const char *filename)
else
{
fullpath = rt_strdup(filename); /* copy string */
if (fullpath == RT_NULL)
return RT_NULL;
}
src = fullpath;
+27 -6
View File
@@ -1,11 +1,26 @@
/*
* File : cmd.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* RT-Thread finsh shell commands
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -604,6 +619,9 @@ long list(void)
index < _syscall_table_end;
FINSH_NEXT_SYSCALL(index))
{
/* skip the internal command */
if (strncpy((char*)index->name, "__", 2) == 0) continue;
#ifdef FINSH_USING_DESCRIPTION
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
#else
@@ -693,6 +711,9 @@ void list_prefix(char *prefix)
index < _syscall_table_end;
FINSH_NEXT_SYSCALL(index))
{
/* skip internal command */
if (str_is_prefix("__", index->name) == 0) continue;
if (str_is_prefix(prefix, index->name) == 0)
{
if (func_cnt == 0)
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_compiler.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* RT-Thread finsh shell compiler
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_error.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* error number for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_error.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* error number for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_heap.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* heap management in finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_heap.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* heap management in finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_init.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* Initialization procedure for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_node.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* node routines for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_node.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* node routines for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_ops.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* operations for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_ops.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* operations for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_parser.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* script parser for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_parser.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* script parser for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_token.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* token lex for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_token.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* token lex for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_var.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* Variable implementation in finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_var.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* Variable implementation in finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_vm.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* Virtual machine finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : finsh_vm.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* Virtual machine finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
File diff suppressed because it is too large. Load diff
+39
View File
@@ -0,0 +1,39 @@
/*
* RT-Thread module shell implementation.
*
* COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2013-03-30 Bernard the first verion for FinSH
*/
#ifndef __M_SHELL__
#define __M_SHELL__
#include <rtthread.h>
rt_bool_t msh_is_used(void);
int msh_exec(char* cmd, rt_size_t length);
void msh_auto_complete(char *prefix);
#endif
File diff suppressed because it is too large. Load diff
+57 -15
View File
@@ -1,15 +1,30 @@
/*
* File : shell.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* shell implementation for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2006-04-30 Bernard the first verion for FinSH
* 2006-04-30 Bernard the first version for FinSH
* 2006-05-08 Bernard change finsh thread stack to 2048
* 2006-06-03 Bernard add support for skyeye
* 2006-09-24 Bernard remove the code related with hardware
@@ -26,6 +41,10 @@
#include "finsh.h"
#include "shell.h"
#ifdef FINSH_USING_MSH
#include "msh.h"
#endif
#ifdef _WIN32
#include <stdio.h> /* for putchar */
#endif
@@ -192,7 +211,17 @@ void finsh_auto_complete(char* prefix)
extern void list_prefix(char* prefix);
rt_kprintf("\n");
list_prefix(prefix);
#ifdef FINSH_USING_MSH
if (msh_is_used() == RT_TRUE)
{
msh_auto_complete(prefix);
}
else
#endif
{
list_prefix(prefix);
}
rt_kprintf("%s%s", FINSH_PROMPT, prefix);
}
@@ -420,15 +449,28 @@ void finsh_thread_entry(void* parameter)
/* handle end of line, break */
if (ch == '\r' || ch == '\n')
{
/* change to ';' and break */
shell->line[shell->line_position] = ';';
#ifdef FINSH_USING_MSH
if (msh_is_used() == RT_TRUE && shell->line_position != 0)
{
rt_kprintf("\n");
msh_exec(shell->line, shell->line_position);
#ifdef FINSH_USING_HISTORY
finsh_push_history(shell);
#endif
}
else
#endif
{
/* add ';' and run the command line */
shell->line[shell->line_position] = ';';
#ifdef FINSH_USING_HISTORY
finsh_push_history(shell);
#endif
#ifdef FINSH_USING_HISTORY
finsh_push_history(shell);
#endif
if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
else rt_kprintf("\n");
if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
else rt_kprintf("\n");
}
rt_kprintf(FINSH_PROMPT);
memset(shell->line, 0, sizeof(shell->line));
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : shell.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
* shell implementation for finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+21 -6
View File
@@ -1,11 +1,26 @@
/*
* File : symbol.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
* symbols in finsh shell.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
*
* This file is part of RT-Thread (http://www.rt-thread.org)
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
+3 -3
View File
@@ -8,14 +8,14 @@ if GetDepend('RT_USING_NEWLIB') and rtconfig.CROSS_TOOL != 'gcc':
exit(0)
cwd = GetCurrentDir()
src = Glob('*.c')
src = Glob('*.c')
CPPPATH = [cwd]
# link with libm in default.
# link with libc and libm:
# libm is a frequently used lib. Newlib is compiled with -ffunction-sections in
# recent GCC tool chains. The linker would just link in the functions that have
# been referenced. So setting this won't result in bigger text size.
LIBS = ['m']
LIBS = ['c', 'm']
group = DefineGroup('newlib', src, depend = ['RT_USING_NEWLIB'],
CPPPATH = CPPPATH, LIBS = LIBS)
+5
View File
@@ -1,10 +1,15 @@
# for network related component
import os
Import('RTT_ROOT')
from building import *
objs = []
list = os.listdir(os.path.join(RTT_ROOT, 'components', 'net'))
# the default version of LWIP is 1.4.0
if not GetDepend('RT_USING_LWIP132') and not GetDepend('RT_USING_LWIP141'):
AddDepend('RT_USING_LWIP140')
for d in list:
path = os.path.join(RTT_ROOT, 'components', 'net', d)
if os.path.isfile(os.path.join(path, 'SConscript')):
+87
View File
@@ -0,0 +1,87 @@
Import('RTT_ROOT')
from building import *
src = Split("""
src/api/api_lib.c
src/api/api_msg.c
src/api/err.c
src/api/netbuf.c
src/api/netdb.c
src/api/netifapi.c
src/api/sockets.c
src/api/tcpip.c
src/arch/sys_arch.c
src/core/def.c
src/core/dhcp.c
src/core/dns.c
src/core/init.c
src/core/memp.c
src/core/netif.c
src/core/pbuf.c
src/core/raw.c
src/core/stats.c
src/core/sys.c
src/core/tcp.c
src/core/tcp_in.c
src/core/tcp_out.c
src/core/timers.c
src/core/udp.c
src/core/ipv4/autoip.c
src/core/ipv4/icmp.c
src/core/ipv4/igmp.c
src/core/ipv4/inet.c
src/core/ipv4/inet_chksum.c
src/core/ipv4/ip.c
src/core/ipv4/ip_addr.c
src/core/ipv4/ip_frag.c
src/netif/etharp.c
src/netif/ethernetif.c
src/netif/slipif.c
""")
snmp_src = Split("""
src/core/snmp/asn1_dec.c
src/core/snmp/asn1_enc.c
src/core/snmp/mib2.c
src/core/snmp/mib_structs.c
src/core/snmp/msg_in.c
src/core/snmp/msg_out.c
""")
ppp_src = Split("""
src/netif/ppp/auth.c
src/netif/ppp/chap.c
src/netif/ppp/chpms.c
src/netif/ppp/fsm.c
src/netif/ppp/ipcp.c
src/netif/ppp/lcp.c
src/netif/ppp/magic.c
src/netif/ppp/md5.c
src/netif/ppp/pap.c
src/netif/ppp/ppp.c
src/netif/ppp/ppp_oe.c
src/netif/ppp/randm.c
src/netif/ppp/vj.c
""")
# The set of source files associated with this SConscript file.
path = [GetCurrentDir() + '/src',
GetCurrentDir() + '/src/include',
GetCurrentDir() + '/src/include/ipv4',
GetCurrentDir() + '/src/arch/include',
GetCurrentDir() + '/src/include/netif']
if GetDepend(['RT_LWIP_SNMP']):
src += snmp_src
if GetDepend(['RT_LWIP_PPP']):
src += ppp_src
path += [GetCurrentDir() + '/src/netif/ppp']
# For testing apps
if GetDepend(['RT_USING_NETUTILS']):
src += Glob('./apps/*.c')
group = DefineGroup('LwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP141'], CPPPATH = path)
Return('group')
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#if defined(__ICCARM__)
#pragma pack(1)
#endif
@@ -0,0 +1,107 @@
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: cc.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $
*/
#ifndef __ARCH_CC_H__
#define __ARCH_CC_H__
#include <rthw.h>
#include <rtthread.h>
typedef rt_uint8_t u8_t;
typedef rt_int8_t s8_t;
typedef rt_uint16_t u16_t;
typedef rt_int16_t s16_t;
typedef rt_uint32_t u32_t;
typedef rt_int32_t s32_t;
typedef rt_uint32_t mem_ptr_t;
#define U16_F "hu"
#define S16_F "hd"
#define X16_F "hx"
#define U32_F "lu"
#define S32_F "ld"
#define X32_F "lx"
#ifdef RT_USING_NEWLIB
#include <errno.h>
/* some errno not defined in newlib */
#define ENSRNOTFOUND 163 /* Domain name not found */
/* WARNING: ESHUTDOWN also not defined in newlib. We chose
180 here because the number "108" which is used
in arch.h has been assigned to another error code. */
#define ESHUTDOWN 180
#elif RT_USING_MINILIBC
#include <errno.h>
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
#else
#define LWIP_PROVIDE_ERRNO
#endif
#ifdef RT_USING_MINILIBC
#include <time.h>
#define LWIP_TIMEVAL_PRIVATE 0
#endif
#if defined(__CC_ARM) /* ARMCC compiler */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_END
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_USE_INCLUDES
#elif defined(__GNUC__) /* GNU GCC Compiler */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__((packed))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#elif defined(_MSC_VER)
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#endif
void sys_arch_assert(const char* file, int line);
#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0)
#define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0)
#include "string.h"
#endif /* __ARCH_CC_H__ */
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#if defined(__ICCARM__)
#pragma pack()
#endif
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: perf.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $
*/
#ifndef __ARCH_PERF_H__
#define __ARCH_PERF_H__
//#include <sys/times.h>
#define PERF_START /* null definition */
#define PERF_STOP(x) /* null definition */
/*
void perf_print(unsigned long c1l, unsigned long c1h,
unsigned long c2l, unsigned long c2h,
char *key);
void perf_print_times(struct tms *start, struct tms *end, char *key);
void perf_init(char *fname);
*/
#endif /* __ARCH_PERF_H__ */
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: sys_arch.h,v 1.3 2005/03/13 16:03:23 bear Exp $
*/
#ifndef __ARCH_SYS_ARCH_H__
#define __ARCH_SYS_ARCH_H__
#include "arch/cc.h"
#include <rtthread.h>
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#define SYS_MBOX_NULL RT_NULL
#define SYS_SEM_NULL RT_NULL
typedef u32_t sys_prot_t;
#define SYS_MBOX_SIZE 10
#define SYS_LWIP_TIMER_NAME "timer"
#define SYS_LWIP_MBOX_NAME "mbox"
#define SYS_LWIP_SEM_NAME "sem"
#define SYS_LWIP_MUTEX_NAME "mu"
typedef rt_sem_t sys_sem_t;
typedef rt_mutex_t sys_mutex_t;
typedef rt_mailbox_t sys_mbox_t;
typedef rt_thread_t sys_thread_t;
#endif /* __ARCH_SYS_ARCH_H__ */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,35 @@
#ifndef __NETIF_ETHERNETIF_H__
#define __NETIF_ETHERNETIF_H__
#include "lwip/netif.h"
#include <rtthread.h>
#define NIOCTL_GADDR 0x01
#define ETHERNET_MTU 1500
struct eth_device
{
/* inherit from rt_device */
struct rt_device parent;
/* network interface for lwip */
struct netif *netif;
struct rt_semaphore tx_ack;
rt_uint8_t flags;
rt_uint8_t link_changed;
rt_uint16_t link_status;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);
rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
rt_err_t eth_device_ready(struct eth_device* dev);
rt_err_t eth_device_init(struct eth_device * dev, char *name);
rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flag);
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
void eth_system_device_init(void);
#endif /* __NETIF_ETHERNETIF_H__ */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -82,6 +82,6 @@ if GetDepend(['RT_LWIP_PPP']):
if GetDepend(['RT_USING_NETUTILS']):
src += Glob('./apps/*.c')
group = DefineGroup('LwIP', src, depend = ['RT_USING_LWIP'], CPPPATH = path)
group = DefineGroup('LwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP140'], CPPPATH = path)
Return('group')
+3 -3
View File
@@ -104,9 +104,9 @@ struct pthread_rwlock
pthread_cond_t rw_condreaders; /* for reader threads waiting */
pthread_cond_t rw_condwriters; /* for writer threads waiting */
int rw_nwaitreaders; /* the number waiting */
int rw_nwaitwriters; /* the number waiting */
int rw_refcount;
int rw_nwaitreaders; /* the number of reader threads waiting */
int rw_nwaitwriters; /* the number of writer threads waiting */
int rw_refcount; /* 0: unlocked, -1: locked by writer, > 0 locked by n readers */
};
typedef struct pthread_rwlock pthread_rwlock_t;
+10 -2
View File
@@ -112,9 +112,11 @@ int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
while (rwlock->rw_refcount < 0 || rwlock->rw_nwaitwriters > 0)
{
rwlock->rw_nwaitreaders++;
/* rw_mutex will be released when waiting for rw_condreaders */
result = pthread_cond_wait(&rwlock->rw_condreaders, &rwlock->rw_mutex);
/* rw_mutex should have been taken again when returned from waiting */
rwlock->rw_nwaitreaders--;
if (result != 0)
if (result != 0) /* wait error */
break;
}
@@ -160,7 +162,9 @@ int pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock, const struct timespec
while (rwlock->rw_refcount < 0 || rwlock->rw_nwaitwriters > 0)
{
rwlock->rw_nwaitreaders++;
/* rw_mutex will be released when waiting for rw_condreaders */
result = pthread_cond_timedwait(&rwlock->rw_condreaders, &rwlock->rw_mutex, abstime);
/* rw_mutex should have been taken again when returned from waiting */
rwlock->rw_nwaitreaders--;
if (result != 0)
break;
@@ -187,7 +191,9 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, const struct timespec
while (rwlock->rw_refcount != 0)
{
rwlock->rw_nwaitwriters++;
/* rw_mutex will be released when waiting for rw_condwriters */
result = pthread_cond_timedwait(&rwlock->rw_condwriters, &rwlock->rw_mutex, abstime);
/* rw_mutex should have been taken again when returned from waiting */
rwlock->rw_nwaitwriters--;
if (result != 0) break;
@@ -233,7 +239,7 @@ int pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
if (rwlock->rw_refcount > 0)
rwlock->rw_refcount--; /* releasing a reader */
else if (rwlock->rw_refcount == -1)
rwlock->rw_refcount = 0; /* releasing a reader */
rwlock->rw_refcount = 0; /* releasing a writer */
/* give preference to waiting writers over waiting readers */
if (rwlock->rw_nwaitwriters > 0)
@@ -264,7 +270,9 @@ int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
while (rwlock->rw_refcount != 0)
{
rwlock->rw_nwaitwriters++;
/* rw_mutex will be released when waiting for rw_condwriters */
result = pthread_cond_wait(&rwlock->rw_condwriters, &rwlock->rw_mutex);
/* rw_mutex should have been taken again when returned from waiting */
rwlock->rw_nwaitwriters--;
if (result != 0) break;
+45
View File
@@ -0,0 +1,45 @@
# Roadmap for RT-Thread 1.2.0 #
The document is the mainly task of RT-Thread 1.2.0. In this series, there will be a full manual document for RT-Thread 1.x series. The format of document is markdown document[0] on github.com and some hardware environment is used in document (RT-Thread Real-Touch[1]).
The document will be wroten in Chinese firstly. At least when RT-Thread 1.2.0 has officially released, the Chinese edition of manual is ready. The manual includes:
1. RT-Thread Kernel (The basic facilities in RTOS)
2. How to port RT-Thread in a new architecture.
3. RT-Thread components.
4. How to debug in RT-Thread.
## Other codes changes in planning ##
### Improvement on bsp porting ###
- LPC18xx & LPC43xx
* USB host and device driver;
- Other BSP.
* welcome contributions.
### New features on Components ###
- device IPC
* implement the work queue[2].
* implement the rwlock[3].
* The APIs are like *BSD, but implement in RT-Thread
- finsh shell
* implement a UNIX style shell, and this shell can execute application module.
- device file system
* implement select[4] API for device object in RT-Thread.
- lwIP TCP/IP stack
* enable IPv6 feature[5].
- gdb server or stub
[0] RT-Thread manual: https://github.com/RT-Thread/manual-doc
[1] RT-Thread Real-Touch: https://github.com/RT-Thread/realtouch-stm32f4
[2] work queue: http://fxr.watson.org/fxr/source/sys/workqueue.h?v=NETBSD
[3] rwlock: http://fxr.watson.org/fxr/source/sys/rwlock.h?v=NETBSD
[4] select API: http://pubs.opengroup.org/onlinepubs/7908799/xsh/select.html
[5] dual IPv4/v6 stack: http://lwip.wikia.com/wiki/LwIP_IPv4/IPv6_stacks
+30 -5
View File
@@ -24,6 +24,9 @@
extern "C" {
#endif
/*
* CPU interfaces
*/
void rt_hw_cpu_icache_enable(void);
void rt_hw_cpu_icache_disable(void);
rt_base_t rt_hw_cpu_icache_status(void);
@@ -38,16 +41,38 @@ rt_uint8_t *rt_hw_stack_init(void *entry,
rt_uint8_t *stack_addr,
void *exit);
/*
* Interrupt handler definition
*/
typedef void (*rt_isr_handler_t)(int vector, void *param);
struct rt_irq_desc {
rt_isr_handler_t handler;
void *param;
#ifdef RT_USING_INTERRUPT_INFO
char name[RT_NAME_MAX];
rt_uint32_t counter;
#endif
};
/*
* Interrupt interfaces
*/
void rt_hw_interrupt_init(void);
void rt_hw_interrupt_mask(int vector);
void rt_hw_interrupt_umask(int vector);
void rt_hw_interrupt_install(int vector,
rt_isr_handler_t new_handler,
rt_isr_handler_t *old_handler);
void rt_hw_interrupt_handle(int vector);
rt_isr_handler_t rt_hw_interrupt_install(int vector,
rt_isr_handler_t handler,
void *param,
char *name);
rt_base_t rt_hw_interrupt_disable(void);
void rt_hw_interrupt_enable(rt_base_t level);
/*
* Context interfaces
*/
void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
void rt_hw_context_switch_to(rt_uint32_t to);
void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);
@@ -58,7 +83,7 @@ void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);
/*
* exception interfaces
* Exception interfaces
*/
void rt_hw_exception_install(rt_err_t (*exception_handle)(void* context));
-1
View File
@@ -425,7 +425,6 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module));
/*
* interrupt service
*/
typedef void (*rt_isr_handler_t)(int vector);
/*
* rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
+30 -7
View File
@@ -10,13 +10,18 @@
* Change Logs:
* Date Author Notes
* 2006-08-23 Bernard first version
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "AT91SAM7X256.h"
#define MAX_HANDLERS 32
/* exception and interrupt handler table */
struct rt_irq_desc irq_desc[MAX_HANDLERS];
extern rt_uint32_t rt_interrupt_nest;
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
@@ -27,7 +32,7 @@ rt_uint32_t rt_thread_switch_interrupt_flag;
*/
/*@{*/
void rt_hw_interrupt_handler(int vector)
static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -35,10 +40,17 @@ void rt_hw_interrupt_handler(int vector)
/**
* This function will initialize hardware interrupt
*/
void rt_hw_interrupt_init()
void rt_hw_interrupt_init(void)
{
rt_base_t index;
/* init exceptions table */
for(index=0; index < MAX_HANDLERS; index++)
{
irq_desc[index].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
irq_desc[index].param = RT_NULL;
}
for (index = 0; index < MAX_HANDLERS; index ++)
{
AT91C_BASE_AIC->AIC_SVR[index] = (rt_uint32_t)rt_hw_interrupt_handler;
@@ -76,16 +88,27 @@ void rt_hw_interrupt_umask(int vector)
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
* @param handler the interrupt service routine to be installed
* @param param the parameter for interrupt service routine
* @name unused.
*
* @return the old handler
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
rt_isr_handler_t old_handler = RT_NULL;
if(vector >= 0 && vector < MAX_HANDLERS)
{
if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t)AT91C_BASE_AIC->AIC_SVR[vector];
if (new_handler != RT_NULL) AT91C_BASE_AIC->AIC_SVR[vector] = (rt_uint32_t)new_handler;
old_handler = irq_desc[vector].handler;
if (handler != RT_NULL)
{
irq_desc[vector].handler = (rt_isr_handler_t)handler;
irq_desc[vector].param = param;
}
}
return old_handler;
}
/*@}*/
+10 -5
View File
@@ -22,23 +22,28 @@
*/
/*@{*/
void rt_hw_trap_irq()
void rt_hw_trap_irq(void)
{
rt_isr_handler_t hander = (rt_isr_handler_t)AT91C_BASE_AIC->AIC_IVR;
int irqno;
extern struct rt_irq_desc irq_desc[];
hander(AT91C_BASE_AIC->AIC_ISR);
/* get interrupt number */
irqno = AT91C_BASE_AIC->AIC_ISR;
/* invoke isr with parameters */
irq_desc[irqno].handler(irqno, irq_desc[irqno].param);
/* end of interrupt */
AT91C_BASE_AIC->AIC_EOICR = 0;
}
void rt_hw_trap_fiq()
void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
extern struct rt_thread* rt_current_thread;
void rt_hw_trap_abort()
void rt_hw_trap_abort(void)
{
rt_kprintf("Abort occured!!! Thread [%s] suspended.\n",rt_current_thread->name);
rt_thread_suspend(rt_current_thread);
+56
View File
@@ -190,4 +190,60 @@ void rt_hw_cpu_shutdown()
}
}
#ifdef RT_USING_CPU_FFS
/**
* This function finds the first bit set (beginning with the least significant bit)
* in value and return the index of that bit.
*
* Bits are numbered starting at 1 (the least significant bit). A return value of
* zero from any of these functions means that the argument was zero.
*
* @return return the index of the first bit set. If value is 0, then this function
* shall return 0.
*/
#if defined(__CC_ARM)
int __rt_ffs(int value)
{
register rt_uint32_t x;
if (value == 0)
return value;
__asm
{
rsb x, value, #0
and x, x, value
clz x, x
rsb x, x, #32
}
return x;
}
#elif defined(__IAR_SYSTEMS_ICC__)
int __rt_ffs(int value)
{
if (value == 0)
return value;
__ASM("RSB r4, r0, #0");
__ASM("AND r4, r4, r0");
__ASM("CLZ r4, r4");
__ASM("RSB r0, r4, #32");
}
#elif defined(__GNUC__)
int __rt_ffs(int value)
{
if (value == 0)
return value;
value &= (-value);
asm ("clz %0, %1": "=r"(value) :"r"(value));
return (32 - value);
}
#endif
#endif
/*@}*/
File diff suppressed because it is too large. Load diff
+6 -3
View File
@@ -138,12 +138,13 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_hw_cpu_shutdown();
}
extern rt_isr_handler_t isr_table[];
extern struct rt_irq_desc irq_desc[];
void rt_hw_trap_irq()
{
rt_isr_handler_t isr_func;
rt_uint32_t irqstat, irq, mask;
void *param;
//rt_kprintf("irq interrupt request\n");
/* get irq number */
irq = at91_sys_read(AT91_AIC_IVR);
@@ -158,11 +159,13 @@ void rt_hw_trap_irq()
//at91_sys_write(AT91_AIC_EOICR, 0x55555555);
/* get interrupt service routine */
isr_func = isr_table[irq];
isr_func = irq_desc[irq].handler;
param = irq_desc[irq].param;
/* turn to interrupt service routine */
isr_func(irq);
isr_func(irq, param);
at91_sys_write(AT91_AIC_EOICR, 0x55555555); //EIOCR must be write any value after interrupt, or else can't response next interrupt
irq_desc[irq].counter ++;
}
void rt_hw_trap_fiq()
+40
View File
@@ -148,3 +148,43 @@ void rt_hw_cpu_shutdown(void)
RT_ASSERT(0);
}
#ifdef RT_USING_CPU_FFS
/**
* This function finds the first bit set (beginning with the least significant bit)
* in value and return the index of that bit.
*
* Bits are numbered starting at 1 (the least significant bit). A return value of
* zero from any of these functions means that the argument was zero.
*
* @return return the index of the first bit set. If value is 0, then this function
* shall return 0.
*/
#if defined(__CC_ARM)
__asm int __rt_ffs(int value)
{
CMP r0, #0x00
BEQ exit
RBIT r0, r0
CLZ r0, r0
ADDS r0, r0, #0x01
exit
BX lr
}
#elif defined(__IAR_SYSTEMS_ICC__)
int __rt_ffs(int value)
{
if (value == 0) return value;
__ASM("RBIT r0, r0");
__ASM("CLZ r0, r0");
__ASM("ADDS r0, r0, #0x01");
}
#elif defined(__GNUC__)
int __rt_ffs(int value)
{
return __builtin_ffs(value);
}
#endif
#endif
+46 -24
View File
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2011-06-15 aozima the first version for lpc214x
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "lpc214x.h"
#define MAX_HANDLERS 32
@@ -20,6 +22,9 @@
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
struct rt_irq_desc irq_desc[MAX_HANDLERS];
/**
* @addtogroup LPC214x
*/
@@ -71,7 +76,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
void rt_hw_interrupt_handler(int vector)
void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -79,7 +84,7 @@ void rt_hw_interrupt_handler(int vector)
/**
* This function will initialize hardware interrupt
*/
void rt_hw_interrupt_init()
void rt_hw_interrupt_init(void)
{
rt_base_t index;
rt_uint32_t *vect_addr, *vect_ctl;
@@ -90,12 +95,15 @@ void rt_hw_interrupt_init()
/* set all to IRQ */
VICIntSelect = 0;
rt_memset(irq_desc, 0x00, sizeof(irq_desc));
for (index = 0; index < MAX_HANDLERS; index ++)
{
irq_desc[index].handler = rt_hw_interrupt_handler;
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + (index << 2));
vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (index << 2));
*vect_addr = (rt_uint32_t)rt_hw_interrupt_handler;
*vect_addr = (rt_uint32_t)&irq_desc[index];
*vect_ctl = 0xF;
}
@@ -127,30 +135,39 @@ void rt_hw_interrupt_umask(int vector)
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
* @param handler the interrupt service routine to be installed
* @param param the interrupt service function parameter
* @param name the interrupt name
* @return old handler
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
if(vector >= 0 && vector < MAX_HANDLERS)
{
/* get VIC address */
rt_uint32_t* vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + (vector << 2));
rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2));
rt_isr_handler_t old_handler = RT_NULL;
/* assign IRQ slot and enable this slot */
*vect_ctl = 0x20 | (vector & 0x1F);
if(vector >= 0 && vector < MAX_HANDLERS)
{
rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2));
if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t) *vect_addr;
if (new_handler != RT_NULL) *vect_addr = (rt_uint32_t) new_handler;
}
/* assign IRQ slot and enable this slot */
*vect_ctl = 0x20 | (vector & 0x1F);
old_handler = irq_desc[vector].handler;
if (handler != RT_NULL)
{
irq_desc[vector].handler = handler;
irq_desc[vector].param = param;
}
}
return old_handler;
}
/**
* this function will reset CPU
*
*/
void rt_hw_cpu_reset()
void rt_hw_cpu_reset(void)
{
}
@@ -165,18 +182,23 @@ void rt_hw_cpu_shutdown()
while (1);
}
void rt_hw_trap_irq()
void rt_hw_trap_irq(void)
{
rt_isr_handler_t isr_func;
int irqno;
struct rt_irq_desc* irq;
extern struct rt_irq_desc irq_desc[];
isr_func = (rt_isr_handler_t) VICVectAddr;
isr_func(0);
irq = (struct rt_irq_desc*) VICVectAddr;
irqno = ((rt_uint32_t) irq - (rt_uint32_t) &irq_desc[0])/sizeof(struct rt_irq_desc);
/* acknowledge Interrupt */
// VICVectAddr = 0;
/* invoke isr */
irq->handler(irqno, irq->param);
/* acknowledge Interrupt */
// VICVectAddr = 0;
}
void rt_hw_trap_fiq()
void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
+37 -19
View File
@@ -10,31 +10,34 @@
* Change Logs:
* Date Author Notes
* 2008-12-11 XuXinming first version
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "LPC24xx.h"
#define MAX_HANDLERS 32
/* exception and interrupt handler table */
struct rt_irq_desc irq_desc[MAX_HANDLERS];
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
/**
* @addtogroup LPC2478
*/
/*@{*/
void rt_hw_interrupt_handle(int vector)
void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
void rt_hw_interrupt_init()
void rt_hw_interrupt_init(void)
{
register int i;
@@ -45,11 +48,15 @@ void rt_hw_interrupt_init()
VICVectAddr = 0;
VICIntSelect = 0;
for ( i = 0; i < 32; i++ )
/* init exceptions table */
rt_memset(irq_desc, 0x00, sizeof(irq_desc));
for(i=0; i < MAX_HANDLERS; i++)
{
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + i*4);
vect_cntl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + i*4);
*vect_addr = 0x0;
irq_desc[i].handler = rt_hw_interrupt_handler;
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + i*4);
vect_cntl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + i*4);
*vect_addr = (rt_uint32_t)&irq_desc[i];
*vect_cntl = 0xF;
}
@@ -70,20 +77,31 @@ void rt_hw_interrupt_umask(int vector)
VICIntEnable = (1 << vector);
}
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param handler the interrupt service routine to be installed
* @param param the parameter for interrupt service routine
* @name unused.
*
* @return the old handler
*/
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
rt_uint32_t *vect_addr;
if(vector < MAX_HANDLERS)
rt_isr_handler_t old_handler = RT_NULL;
if(vector >= 0 && vector < MAX_HANDLERS)
{
/* find first un-assigned VIC address for the handler */
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + vector*4);
/* get old handler */
if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t)*vect_addr;
*vect_addr = (rt_uint32_t)new_handler; /* set interrupt vector */
old_handler = irq_desc[vector].handler;
if (handler != RT_NULL)
{
irq_desc[vector].handler = handler;
irq_desc[vector].param = param;
}
}
return old_handler;
}
/*@}*/
+10 -7
View File
@@ -126,17 +126,20 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
}
extern rt_isr_handler_t isr_table[];
void rt_hw_trap_irq()
void rt_hw_trap_irq(void)
{
rt_isr_handler_t isr_func;
isr_func = (rt_isr_handler_t) VICVectAddr;
int irqno;
struct rt_irq_desc* irq;
extern struct rt_irq_desc irq_desc[];
/* fixme, how to get interrupt number */
isr_func(0);
irq = (struct rt_irq_desc*) VICVectAddr;
irqno = ((rt_uint32_t) irq - (rt_uint32_t) &irq_desc[0])/sizeof(struct rt_irq_desc);
/* invoke isr */
irq->handler(irqno, irq->param);
}
void rt_hw_trap_fiq()
void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
+47 -32
View File
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "s3c24x0.h"
#define MAX_HANDLERS 32
@@ -20,7 +22,7 @@
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
rt_isr_handler_t isr_table[MAX_HANDLERS];
struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
@@ -29,10 +31,9 @@ rt_uint32_t rt_thread_switch_interrupt_flag;
*/
/*@{*/
rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
static void rt_hw_interrupt_handle(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
return RT_NULL;
}
/**
@@ -40,37 +41,38 @@ rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
*/
void rt_hw_interrupt_init(void)
{
register rt_uint32_t idx;
register rt_uint32_t idx;
/* all clear source pending */
SRCPND = 0x0;
/* all clear source pending */
SRCPND = 0x0;
/* all clear sub source pending */
SUBSRCPND = 0x0;
/* all clear sub source pending */
SUBSRCPND = 0x0;
/* all=IRQ mode */
INTMOD = 0x0;
/* all=IRQ mode */
INTMOD = 0x0;
/* all interrupt disabled include global bit */
INTMSK = BIT_ALLMSK;
/* all interrupt disabled include global bit */
INTMSK = BIT_ALLMSK;
/* all sub interrupt disable */
INTSUBMSK = BIT_SUB_ALLMSK;
/* all sub interrupt disable */
INTSUBMSK = BIT_SUB_ALLMSK;
/* all clear interrupt pending */
INTPND = BIT_ALLMSK;
/* all clear interrupt pending */
INTPND = BIT_ALLMSK;
/* init exceptions table */
for(idx=0; idx < MAX_HANDLERS; idx++)
{
isr_table[idx] = (rt_isr_handler_t)rt_hw_interrupt_handle;
}
/* init exceptions table */
rt_memset(isr_table, 0x00, sizeof(isr_table));
for(idx=0; idx < MAX_HANDLERS; idx++)
{
isr_table[idx].handler = rt_hw_interrupt_handle;
}
/* init interrupt nest, and context in thread sp */
rt_interrupt_nest = 0;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = 0;
rt_thread_switch_interrupt_flag = 0;
/* init interrupt nest, and context in thread sp */
rt_interrupt_nest = 0;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = 0;
rt_thread_switch_interrupt_flag = 0;
}
/**
@@ -105,13 +107,26 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
if(vector < MAX_HANDLERS)
{
if (old_handler != RT_NULL) *old_handler = isr_table[vector];
if (new_handler != RT_NULL) isr_table[vector] = new_handler;
}
rt_isr_handler_t old_handler = RT_NULL;
if(vector < MAX_HANDLERS)
{
old_handler = isr_table[vector].handler;
if (handler != RT_NULL)
{
#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */
isr_table[vector].handler = handler;
isr_table[vector].param = param;
}
}
return old_handler;
}
/*@}*/
+21 -14
View File
@@ -12,6 +12,7 @@
* 2006-03-13 Bernard first version
* 2006-05-27 Bernard add skyeye support
* 2007-11-19 Yi.Qiu fix rt_hw_trap_irq function
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
@@ -140,29 +141,35 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_hw_cpu_shutdown();
}
extern rt_isr_handler_t isr_table[];
extern struct rt_irq_desc isr_table[];
void rt_hw_trap_irq()
void rt_hw_trap_irq(void)
{
unsigned long intstat;
rt_isr_handler_t isr_func;
unsigned long irq;
rt_isr_handler_t isr_func;
void *param;
intstat = INTOFFSET;
irq = INTOFFSET;
if (intstat == INTGLOBAL) return;
if (irq == INTGLOBAL) return;
/* get interrupt service routine */
isr_func = isr_table[intstat];
/* get interrupt service routine */
isr_func = isr_table[irq].handler;
param = isr_table[irq].param;
/* turn to interrupt service routine */
isr_func(intstat);
/* turn to interrupt service routine */
isr_func(irq, param);
/* clear pending register */
/* note: must be the last, if not, may repeat*/
ClearPending(1 << intstat);
/* clear pending register */
/* note: must be the last, if not, may repeat*/
ClearPending(1 << irq);
#ifdef RT_USING_INTERRUPT_INFO
isr_table[irq].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
}
void rt_hw_trap_fiq()
void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
+50 -36
View File
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include <sep4020.h>
#define MAX_HANDLERS 32
@@ -20,7 +22,7 @@
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
rt_isr_handler_t isr_table[MAX_HANDLERS];
struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
@@ -38,44 +40,45 @@ rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
/**
* This function will initialize hardware interrupt
*/
void rt_hw_interrupt_init()
void rt_hw_interrupt_init(void)
{
register rt_uint32_t idx;
register rt_uint32_t idx;
/*Make sure all intc registers in proper state*/
/*Make sure all intc registers in proper state*/
/*mask all the irq*/
*(RP)(INTC_IMR) = 0xFFFFFFFF;
/*mask all the irq*/
*(RP)(INTC_IMR) = 0xFFFFFFFF;
/*enable all the irq*/
*(RP)(INTC_IER) = 0XFFFFFFFF;
/*enable all the irq*/
*(RP)(INTC_IER) = 0XFFFFFFFF;
/*Dont use any forced irq*/
*(RP)(INTC_IFR) = 0x0;
/*Dont use any forced irq*/
*(RP)(INTC_IFR) = 0x0;
/*Disable all the fiq*/
*(RP)(INTC_FIER) = 0x0;
/*Disable all the fiq*/
*(RP)(INTC_FIER) = 0x0;
/*Mask all the fiq*/
*(RP)(INTC_FIMR) = 0x0F;
/*Mask all the fiq*/
*(RP)(INTC_FIMR) = 0x0F;
/*Dont use forced fiq*/
*(RP)(INTC_FIFR) = 0x0;
/*Dont use forced fiq*/
*(RP)(INTC_FIFR) = 0x0;
/*Intrrupt priority register*/
*(RP)(INTC_IPLR) = 0x0;
/*Intrrupt priority register*/
*(RP)(INTC_IPLR) = 0x0;
/* init exceptions table */
for(idx=0; idx < MAX_HANDLERS; idx++)
{
isr_table[idx] = (rt_isr_handler_t)rt_hw_interrupt_handle;
}
/* init exceptions table */
rt_memset(isr_table, 0x00, sizeof(isr_table));
for(idx=0; idx < MAX_HANDLERS; idx++)
{
isr_table[idx].handler = rt_hw_interrupt_handle;
}
/* init interrupt nest, and context in thread sp */
rt_interrupt_nest = 0;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = 0;
rt_thread_switch_interrupt_flag = 0;
/* init interrupt nest, and context in thread sp */
rt_interrupt_nest = 0;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = 0;
rt_thread_switch_interrupt_flag = 0;
}
/**
@@ -108,15 +111,26 @@ void rt_hw_interrupt_umask(rt_uint32_t vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
void rt_hw_interrupt_install(rt_uint32_t vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
if(vector < MAX_HANDLERS)
{
if (*old_handler != RT_NULL)
*old_handler = isr_table[vector];
if (new_handler != RT_NULL)
isr_table[vector] = new_handler;
}
rt_isr_handler_t old_handler = RT_NULL;
if(vector < MAX_HANDLERS)
{
old_handler = isr_table[vector].handler;
if (handler != RT_NULL)
{
#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */
isr_table[vector].handler = handler;
isr_table[vector].param = param;
}
}
return old_handler;
}
/*@}*/
+26 -18
View File
@@ -12,6 +12,7 @@
* 2006-03-13 Bernard first version
* 2006-05-27 Bernard add skyeye support
* 2007-11-19 Yi.Qiu fix rt_hw_trap_irq function
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
@@ -131,31 +132,38 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_hw_cpu_shutdown();
}
extern rt_isr_handler_t isr_table[];
extern struct rt_irq_desc isr_table[];
void rt_hw_trap_irq()
void rt_hw_trap_irq(void)
{
unsigned long intstat;
rt_uint32_t i = 0;
rt_isr_handler_t isr_func;
unsigned long intstat;
rt_uint32_t irq = 0;
rt_isr_handler_t isr_func;
void *param;
/*Get the final intrrupt source*/
intstat = *(RP)(INTC_IFSR);;
/*Get the final intrrupt source*/
intstat = *(RP)(INTC_IFSR);;
/*Shift to get the intrrupt number*/
while(intstat != 1)
{
intstat = intstat >> 1;
i++;
}
/* get interrupt service routine */
isr_func = isr_table[i];
/*Shift to get the intrrupt number*/
while(intstat != 1)
{
intstat = intstat >> 1;
irq++;
}
/* turn to interrupt service routine */
isr_func(i);
/* get interrupt service routine */
isr_func = isr_table[irq].isr_handle;
param = isr_table[irq].param;
/* turn to interrupt service routine */
isr_func(irq, param);
#ifdef RT_USING_INTERRUPT_INFO
isr_table[irq].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
}
void rt_hw_trap_fiq()
void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
+29 -12
View File
@@ -11,7 +11,7 @@
* Date Author Notes
* 2010-07-09 Bernard first version
*/
#include <rtthread.h>
#include <rthw.h>
#include "jz47xx.h"
#define JZ47XX_MAX_INTR 32
@@ -20,7 +20,7 @@ extern rt_uint32_t rt_interrupt_nest;
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
static rt_isr_handler_t irq_handle_table[JZ47XX_MAX_INTR];
static struct rt_irq_desc irq_handle_table[JZ47XX_MAX_INTR];
/**
* @addtogroup Jz47xx
@@ -39,9 +39,10 @@ void rt_hw_interrupt_init()
{
rt_int32_t index;
rt_memset(irq_handle_table, 0x00, sizeof(irq_handle_table));
for (index = 0; index < JZ47XX_MAX_INTR; index ++)
{
irq_handle_table[index] = (rt_isr_handler_t)rt_hw_interrupt_handler;
irq_handle_table[index].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
}
/* init interrupt nest, and context in thread sp */
@@ -73,18 +74,30 @@ void rt_hw_interrupt_umask(int vector)
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
* @param handler the interrupt service routine to be installed
* @param param the interrupt service function parameter
* @param name the interrupt name
* @return old handler
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector,
rt_isr_handler_t handler,
void *param,
char *name)
{
rt_isr_handler_t old_handler = RT_NULL;
if (vector >= 0 && vector < JZ47XX_MAX_INTR)
{
if (old_handler != RT_NULL)
*old_handler = irq_handle_table[vector];
if (new_handler != RT_NULL)
irq_handle_table[vector] = (rt_isr_handler_t)new_handler;
old_handler = irq_handle_table[vector].handler;
#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */
irq_handle_table[vector].handler = handler;
irq_handle_table[vector].param = param;
}
return old_handler;
}
void rt_interrupt_dispatch(void *ptreg)
@@ -102,10 +115,14 @@ void rt_interrupt_dispatch(void *ptreg)
if ((pending & (1<<i)))
{
pending &= ~(1<<i);
irq_func = irq_handle_table[i];
irq_func = irq_handle_table[i].handler;
/* do interrupt */
(*irq_func)(i);
(*irq_func)(i, irq_handle_table[i].param);
#ifdef RT_USING_INTERRUPT_INFO
irq_handle_table[i].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
/* ack interrupt */
INTC_IPR = (1 << i);
+64 -42
View File
@@ -10,8 +10,11 @@
* Change Logs:
* Date Author Notes
* 2010-10-15 Bernard first version
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "soc3210.h"
#define MAX_INTR 32
@@ -20,17 +23,17 @@ extern rt_uint32_t rt_interrupt_nest;
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
static rt_isr_handler_t irq_handle_table[MAX_INTR];
static struct rt_irq_desc irq_handle_table[MAX_INTR];
void rt_interrupt_dispatch(void *ptreg);
void rt_hw_timer_handler();
/**
* @addtogroup Loongson SoC3210
*/
/*@{*/
void rt_hw_interrupt_handler(int vector)
static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -40,11 +43,12 @@ void rt_hw_interrupt_handler(int vector)
*/
void rt_hw_interrupt_init(void)
{
rt_int32_t index;
rt_int32_t idx;
for (index = 0; index < MAX_INTR; index ++)
rt_memset(irq_handle_table, 0x00, sizeof(irq_handle_table));
for (idx = 0; idx < MAX_INTR; idx ++)
{
irq_handle_table[index] = (rt_isr_handler_t)rt_hw_interrupt_handler;
irq_handle_table[idx].handler = rt_hw_interrupt_handler;
}
/* init interrupt nest, and context in thread sp */
@@ -79,52 +83,70 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
if (vector >= 0 && vector < MAX_INTR)
{
if (old_handler != RT_NULL)
*old_handler = irq_handle_table[vector];
if (new_handler != RT_NULL)
irq_handle_table[vector] = (rt_isr_handler_t)new_handler;
}
rt_isr_handler_t old_handler = RT_NULL;
if(vector < MAX_INTR)
{
old_handler = irq_handle_table[vector].handler;
if (handler != RT_NULL)
{
#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */
irq_handle_table[vector].handler = handler;
irq_handle_table[vector].param = param;
}
}
return old_handler;
}
void rt_interrupt_dispatch(void *ptreg)
{
int i;
rt_isr_handler_t irq_func;
static rt_uint32_t status = 0;
rt_uint32_t c0_status;
int irq;
void *param;
rt_isr_handler_t irq_func;
static rt_uint32_t status = 0;
rt_uint32_t c0_status;
/* check os timer */
c0_status = read_c0_status();
if (c0_status & 0x8000)
{
rt_hw_timer_handler();
}
/* check os timer */
c0_status = read_c0_status();
if (c0_status & 0x8000)
{
rt_hw_timer_handler();
}
if (c0_status & 0x0400)
{
/* the hardware interrupt */
status |= INT_ISR;
if (!status) return;
if (c0_status & 0x0400)
{
/* the hardware interrupt */
status |= INT_ISR;
if (!status) return;
for (i = MAX_INTR; i > 0; --i)
{
if ((status & (1<<i)))
{
status &= ~(1<<i);
irq_func = irq_handle_table[i];
for (irq = MAX_INTR; irq > 0; --irq)
{
if ((status & (1 << irq)))
{
status &= ~(1 << irq);
/* do interrupt */
(*irq_func)(i);
irq_func = irq_handle_table[irq].handler;
param = irq_handle_table[irq].param;
/* ack interrupt */
INT_CLR = (1 << i);
}
}
}
/* do interrupt */
(*irq_func)(irq, param);
#ifdef RT_USING_INTERRUPT_INFO
irq_handle_table[irq].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
/* ack interrupt */
INT_CLR = (1 << irq);
}
}
}
}
/*@}*/
+39 -18
View File
@@ -11,9 +11,11 @@
* Date Author Notes
* 2010-10-15 Bernard first version
* 2010-10-15 lgnq modified for LS1B
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
#include <rthw.h>
#include "ls1b.h"
#define MAX_INTR 32
@@ -23,7 +25,7 @@ rt_uint32_t rt_interrupt_from_thread;
rt_uint32_t rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
static rt_isr_handler_t irq_handle_table[MAX_INTR];
static struct rt_irq_desc irq_handle_table[MAX_INTR];
void rt_interrupt_dispatch(void *ptreg);
void rt_hw_timer_handler();
@@ -36,7 +38,7 @@ static struct ls1b_intc_regs volatile *ls1b_hw0_icregs
/*@{*/
void rt_hw_interrupt_handler(int vector)
static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -46,7 +48,7 @@ void rt_hw_interrupt_handler(int vector)
*/
void rt_hw_interrupt_init(void)
{
rt_int32_t index;
rt_int32_t idx;
/* pci active low */
ls1b_hw0_icregs->int_pol = -1; //must be done here 20110802 lgnq
@@ -55,9 +57,10 @@ void rt_hw_interrupt_init(void)
/* mask all interrupts */
(ls1b_hw0_icregs+0)->int_clr = 0xffffffff;
for (index = 0; index < MAX_INTR; index ++)
rt_memset(irq_handle_table, 0x00, sizeof(irq_handle_table));
for (idx = 0; idx < MAX_INTR; idx ++)
{
irq_handle_table[index] = (rt_isr_handler_t)rt_hw_interrupt_handler;
irq_handle_table[idx].handler = rt_hw_interrupt_handler;
}
/* init interrupt nest, and context in thread sp */
@@ -92,20 +95,32 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
rt_isr_handler_t old_handler = RT_NULL;
if (vector >= 0 && vector < MAX_INTR)
{
if (old_handler != RT_NULL)
*old_handler = irq_handle_table[vector];
if (new_handler != RT_NULL)
irq_handle_table[vector] = (rt_isr_handler_t)new_handler;
}
old_handler = irq_handle_table[vector].handler;
if (handler != RT_NULL)
{
#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */
irq_handle_table[vector].handler = handler;
irq_handle_table[vector].param = param;
}
}
return old_handler;
}
void rt_interrupt_dispatch(void *ptreg)
{
int i;
int irq;
void *param;
rt_isr_handler_t irq_func;
static rt_uint32_t status = 0;
rt_uint32_t c0_status;
@@ -134,18 +149,24 @@ void rt_interrupt_dispatch(void *ptreg)
if (!status)
return;
for (i = MAX_INTR; i > 0; --i)
for (irq = MAX_INTR; irq > 0; --irq)
{
if ((status & (1<<i)))
if ((status & (1 << irq)))
{
status &= ~(1<<i);
irq_func = irq_handle_table[i];
status &= ~(1 << irq);
irq_func = irq_handle_table[irq].handler;
param = irq_handle_table[irq].param;
/* do interrupt */
(*irq_func)(i);
(*irq_func)(irq, param);
#ifdef RT_USING_INTERRUPT_INFO
irq_handle_table[irq].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
/* ack interrupt */
ls1b_hw0_icregs->int_clr |= (1 << i);
ls1b_hw0_icregs->int_clr |= (1 << irq);
}
}
}
+15 -11
View File
@@ -12,7 +12,7 @@
* 2009-01-05 Bernard first version
*/
#include <rtthread.h>
#include <rthw.h>
#include <asm/ppc4xx.h>
#include <asm/processor.h>
@@ -21,12 +21,12 @@ extern volatile rt_uint8_t rt_interrupt_nest;
/* exception and interrupt handler table */
#define MAX_HANDLERS 32
rt_isr_handler_t isr_table[MAX_HANDLERS];
struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrput_flag;
rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
rt_isr_handler_t rt_hw_interrupt_handler(rt_uint32_t vector, void* param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
return RT_NULL;
@@ -42,9 +42,9 @@ void uic_int_handler (unsigned int vec)
rt_interrupt_enter();
/* Allow external interrupts to the CPU. */
if (isr_table [vec] != 0)
if (isr_table [vec].handler != 0)
{
(*isr_table[vec])(vec);
(*isr_table[vec].handler)(vec, isr_table[vec].param);
}
uic_irq_ack(vec);
@@ -78,21 +78,24 @@ void uic_interrupt(rt_uint32_t uic_base, int vec_base)
}
}
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler,
void* param, char* name)
{
int intVal;
rt_isr_handler_t old_handler;
if (((int)vector < 0) || ((int) vector >= MAX_HANDLERS))
{
return; /* out of range */
return RT_NULL; /* out of range */
}
/* install the handler in the system interrupt table */
intVal = rt_hw_interrupt_disable (); /* lock interrupts to prevent races */
if (*old_handler != RT_NULL) *old_handler = isr_table[vector];
if (new_handler != RT_NULL) isr_table[vector] = new_handler;
old_handler = isr_table[vector].handler;
isr_table[vector].handler = new_handler;
isr_table[vector].param = param;
rt_hw_interrupt_enable (intVal);
}
@@ -120,7 +123,8 @@ void rt_hw_interrupt_init()
/* set default interrupt handler */
for (vector = 0; vector < MAX_HANDLERS; vector++)
{
isr_table [vector] = (rt_isr_handler_t)rt_hw_interrupt_handle;
isr_table [vector].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
isr_table [vector].param = RT_NULL;
}
/* initialize interrupt nest, and context in thread sp */
+3 -3
View File
@@ -220,12 +220,12 @@ void rt_serial_set_baudrate(struct rt_ppc405_serial* device)
out_8((rt_uint8_t *)device->hw_base + UART_DLM, bdiv >> 8); /* set baudrate divisor */
}
void rt_serial_isr(int irqno)
void rt_serial_isr(int irqno, void* param)
{
unsigned char status;
struct rt_ppc405_serial *device;
device = (struct rt_ppc405_serial*) &ppc405_serial;
device = (struct rt_ppc405_serial*) param;
status = in_8((rt_uint8_t *)device->hw_base + UART_LSR);
if (status & 0x01)
@@ -289,7 +289,7 @@ void rt_hw_serial_init(void)
device->hw_base = UART0_BASE;
device->baudrate = 115200;
device->irqno = VECNUM_U0;
rt_hw_interrupt_install(device->irqno, rt_serial_isr, RT_NULL); /* install isr */
rt_hw_interrupt_install(device->irqno, rt_serial_isr, device, "serial"); /* install isr */
rt_memset(device->rx_buffer, 0, sizeof(device->rx_buffer));
device->read_index = device->save_index = 0;
+48
View File
@@ -1190,6 +1190,54 @@ void rt_free_align(void *ptr)
RTM_EXPORT(rt_free_align);
#endif
#ifndef RT_USING_CPU_FFS
const rt_uint8_t __lowest_bit_bitmap[] =
{
/* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 10 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 20 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 30 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 40 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 50 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 60 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 70 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 80 */ 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 90 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* A0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* B0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* C0 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* D0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* E0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* F0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
/**
* This function finds the first bit set (beginning with the least significant bit)
* in value and return the index of that bit.
*
* Bits are numbered starting at 1 (the least significant bit). A return value of
* zero from any of these functions means that the argument was zero.
*
* @return return the index of the first bit set. If value is 0, then this function
* shall return 0.
*/
int __rt_ffs(int value)
{
if (value == 0) return 0;
if (value & 0xff)
return __lowest_bit_bitmap[value & 0xff] + 1;
if (value & 0xff00)
return __lowest_bit_bitmap[(value & 0xff00) >> 8] + 9;
if (value & 0xff0000)
return __lowest_bit_bitmap[(value & 0xff0000) >> 16] + 17;
return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25;
}
#endif
#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) && defined (__GNUC__)
#include <sys/types.h>
void *memcpy(void *dest, const void *src, size_t n) __attribute__((weak, alias("rt_memcpy")));
+11 -71
View File
@@ -31,6 +31,7 @@
static rt_int16_t rt_scheduler_lock_nest;
extern volatile rt_uint8_t rt_interrupt_nest;
extern int __rt_ffs(int value);
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
struct rt_thread *rt_current_thread;
@@ -48,26 +49,6 @@ rt_uint32_t rt_thread_ready_priority_group;
rt_list_t rt_thread_defunct;
const rt_uint8_t rt_lowest_bitmap[] =
{
/* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 10 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 20 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 30 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 40 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 50 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 60 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 70 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 80 */ 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 90 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* A0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* B0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* C0 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* D0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* E0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* F0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
#ifdef RT_USING_HOOK
static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to);
@@ -164,34 +145,13 @@ void rt_system_scheduler_start(void)
register struct rt_thread *to_thread;
register rt_ubase_t highest_ready_priority;
#if RT_THREAD_PRIORITY_MAX == 8
highest_ready_priority = rt_lowest_bitmap[rt_thread_ready_priority_group];
#else
register rt_ubase_t number;
/* find out the highest priority task */
if (rt_thread_ready_priority_group & 0xff)
{
number = rt_lowest_bitmap[rt_thread_ready_priority_group & 0xff];
}
else if (rt_thread_ready_priority_group & 0xff00)
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 8) & 0xff] + 8;
}
else if (rt_thread_ready_priority_group & 0xff0000)
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 16) & 0xff] + 16;
}
else
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 24) & 0xff] + 24;
}
#if RT_THREAD_PRIORITY_MAX > 32
highest_ready_priority = (number << 3) +
rt_lowest_bitmap[rt_thread_ready_table[number]];
register rt_ubase_t number;
number = __rt_ffs(rt_thread_ready_priority_group) - 1;
highest_ready_priority = (number << 3) + __rt_ffs(rt_thread_ready_table[number]) - 1;
#else
highest_ready_priority = number;
#endif
highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1;
#endif
/* get switch to thread */
@@ -231,35 +191,15 @@ void rt_schedule(void)
{
register rt_ubase_t highest_ready_priority;
#if RT_THREAD_PRIORITY_MAX == 8
highest_ready_priority = rt_lowest_bitmap[rt_thread_ready_priority_group];
#if RT_THREAD_PRIORITY_MAX <= 32
highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1;
#else
register rt_ubase_t number;
/* find out the highest priority task */
if (rt_thread_ready_priority_group & 0xff)
{
number = rt_lowest_bitmap[rt_thread_ready_priority_group & 0xff];
}
else if (rt_thread_ready_priority_group & 0xff00)
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 8) & 0xff] + 8;
}
else if (rt_thread_ready_priority_group & 0xff0000)
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 16) & 0xff] + 16;
}
else
{
number = rt_lowest_bitmap[(rt_thread_ready_priority_group >> 24) & 0xff] + 24;
}
#if RT_THREAD_PRIORITY_MAX > 32
highest_ready_priority = (number << 3) +
rt_lowest_bitmap[rt_thread_ready_table[number]];
#else
highest_ready_priority = number;
#endif
number = __rt_ffs(rt_thread_ready_priority_group) - 1;
highest_ready_priority = (number << 3) + __rt_ffs(rt_thread_ready_table[number]) - 1;
#endif
/* get switch to thread */
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
struct rt_thread,