[PATCH 2/3] Mailbox : Added functionality to get power state
From: Mudit Jain --- c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 2 ++ c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 25 ++ c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 12 +++ 3 files changed, 39 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h index d3408f9..74f7557 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h @@ -106,6 +106,8 @@ typedef struct { #define BCM2835_MAILBOX_POWER_STATE_NODEV ( 1 << 1 ) int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries ); +int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries ); + typedef struct { uint32_t base; size_t size; diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c index 53ac1e8..c089b36 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c @@ -254,6 +254,31 @@ int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries ) return 0; } +int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_power_state get_power_state; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG( &buffer.get_power_state, +BCM2835_MAILBOX_TAG_GET_POWER_STATE ); + buffer.get_power_state.body.req.dev_id = _entries->dev_id; + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->dev_id = buffer.get_power_state.body.resp.dev_id; + _entries->state = buffer.get_power_state.body.resp.state; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} + int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries ) { struct { diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h index 516f8f4..e1a5a5b 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h @@ -246,6 +246,18 @@ typedef struct { #define BCM2835_MAILBOX_POWER_UDID_CCP2TX0x0008 #define BCM2835_MAILBOX_TAG_GET_POWER_STATE 0x00020001 +typedef struct { + bcm2835_mbox_tag_hdr tag_hdr; + union { +struct { + uint32_t dev_id; +} req; +struct { + uint32_t dev_id; + uint32_t state; +} resp; + } body; +} bcm2835_mbox_tag_get_power_state; #define BCM2835_MAILBOX_POWER_STATE_RESP_ON (1 << 0) #define BCM2835_MAILBOX_POWER_STATE_RESP_NODEV(1 << 1) -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 3/3] Mailbox : Adding functionality to get clock rate
From: Mudit Jain --- c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 8 +++ c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 26 ++ c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 12 ++ 3 files changed, 46 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h index 74f7557..e863732 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h @@ -144,6 +144,14 @@ typedef struct { int bcm2835_mailbox_get_board_serial( bcm2835_get_board_serial_entries *_entries ); + +typedef struct { + uint32_t clock_id; + uint32_t clock_rate; +} bcm2835_get_clock_rate_entries; + +int bcm2835_mailbox_get_clock_rate( + bcm2835_get_clock_rate_entries *_entries ); /** @} */ #endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c index c089b36..df92649 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c @@ -447,3 +447,29 @@ int bcm2835_mailbox_get_board_serial( return 0; } + +int bcm2835_mailbox_get_clock_rate( + bcm2835_get_clock_rate_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_clock_rate get_clock_rate; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_clock_rate, +BCM2835_MAILBOX_TAG_GET_CLOCK_RATE ); + buffer.get_clock_rate.body.req.clock_id = _entries->clock_id; + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->clock_id = buffer.get_clock_rate.body.resp.clock_id; + _entries->clock_rate = buffer.get_clock_rate.body.resp.clock_rate; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h index e1a5a5b..48d1658 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h @@ -217,6 +217,18 @@ typedef struct { } bcm2835_mbox_tag_get_vc_memory; #define BCM2835_MAILBOX_TAG_GET_CLOCKS 0x00010007 +typedef struct { + bcm2835_mbox_tag_hdr tag_hdr; + union { +struct { + uint32_t clock_id; +} req; +struct { + uint32_t clock_id; + uint32_t clock_rate; +} resp; + } body; +} bcm2835_mbox_tag_get_clock_rate; /* Config */ #define BCM2835_MAILBOX_TAG_GET_CMD_LINE0x00050001 -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] Mailbox : Extending functionality
Adding functionality to get board serial, power state & clock rate --- c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 17 + c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 75 ++ c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 35 ++ 3 files changed, 127 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h index 00414ff..e863732 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h @@ -106,6 +106,8 @@ typedef struct { #define BCM2835_MAILBOX_POWER_STATE_NODEV ( 1 << 1 ) int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries ); +int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries ); + typedef struct { uint32_t base; size_t size; @@ -135,6 +137,21 @@ int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries ); int bcm2835_mailbox_get_board_revision( bcm2835_get_board_spec_entries *_entries ); + +typedef struct { + uint64_t board_serial; +} bcm2835_get_board_serial_entries; + +int bcm2835_mailbox_get_board_serial( + bcm2835_get_board_serial_entries *_entries ); + +typedef struct { + uint32_t clock_id; + uint32_t clock_rate; +} bcm2835_get_clock_rate_entries; + +int bcm2835_mailbox_get_clock_rate( + bcm2835_get_clock_rate_entries *_entries ); /** @} */ #endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c index 0bec0c2..df92649 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c @@ -254,6 +254,31 @@ int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries ) return 0; } +int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_power_state get_power_state; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG( &buffer.get_power_state, +BCM2835_MAILBOX_TAG_GET_POWER_STATE ); + buffer.get_power_state.body.req.dev_id = _entries->dev_id; + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->dev_id = buffer.get_power_state.body.resp.dev_id; + _entries->state = buffer.get_power_state.body.resp.state; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} + int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries ) { struct { @@ -398,3 +423,53 @@ int bcm2835_mailbox_get_board_revision( return 0; } + +int bcm2835_mailbox_get_board_serial( + bcm2835_get_board_serial_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_board_serial get_board_serial; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_serial, +BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL ); + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->board_serial = buffer.get_board_serial.body.resp.board_serial; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} + +int bcm2835_mailbox_get_clock_rate( + bcm2835_get_clock_rate_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_clock_rate get_clock_rate; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_clock_rate, +BCM2835_MAILBOX_TAG_GET_CLOCK_RATE ); + buffer.get_clock_rate.body.req.clock_id = _entries->clock_id; + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->clock_id = buffer.get_clock_rate.body.resp.clock_id; + _entries->clock_rate = buffer.get_clock_rate.body.resp.clock_rate; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h index 8d1067b..48d1658 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h @@ -179,6 +179,17 @@ typedef struct { #define BCM2835_MAILBOX_TAG_GET_BOARD_MAC 0x00010003 #define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL0x00010004 +typedef struct { + bcm2835_mbox_tag_hdr tag_hdr; + union { +struct { +} req; +struct { + uint64_t board_serial; +} resp; + } body; +} bcm2835_mbox_tag_get_board_serial;
Re: [PATCH 1/3] Mailbox : Adding functionality to get board serial
Kindly ignore this. I have rebased and pushed all the changes in one patch. Thanks Mudit ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/3] Mailbox : Adding functionality to get board serial
From: Mudit Jain --- c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 7 +++ c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 24 ++ c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 11 ++ 3 files changed, 42 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h index 00414ff..d3408f9 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h @@ -135,6 +135,13 @@ int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries ); int bcm2835_mailbox_get_board_revision( bcm2835_get_board_spec_entries *_entries ); + +typedef struct { + uint64_t board_serial; +} bcm2835_get_board_serial_entries; + +int bcm2835_mailbox_get_board_serial( + bcm2835_get_board_serial_entries *_entries ); /** @} */ #endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c index 0bec0c2..53ac1e8 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c @@ -398,3 +398,27 @@ int bcm2835_mailbox_get_board_revision( return 0; } + +int bcm2835_mailbox_get_board_serial( + bcm2835_get_board_serial_entries *_entries ) +{ + struct { +bcm2835_mbox_buf_hdr hdr; +bcm2835_mbox_tag_get_board_serial get_board_serial; +uint32_t end_tag; + } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE; + BCM2835_MBOX_INIT_BUF( &buffer ); + BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_serial, +BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL ); + bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) ); + + if ( bcm2835_mailbox_send_read_buffer( &buffer ) ) +return -1; + + _entries->board_serial = buffer.get_board_serial.body.resp.board_serial; + + if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) ) +return -2; + + return 0; +} diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h index 8d1067b..516f8f4 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h @@ -179,6 +179,17 @@ typedef struct { #define BCM2835_MAILBOX_TAG_GET_BOARD_MAC 0x00010003 #define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL0x00010004 +typedef struct { + bcm2835_mbox_tag_hdr tag_hdr; + union { +struct { +} req; +struct { + uint64_t board_serial; +} resp; + } body; +} bcm2835_mbox_tag_get_board_serial; + #define BCM2835_MAILBOX_TAG_GET_ARM_MEMORY 0x00010005 typedef struct { bcm2835_mbox_tag_hdr tag_hdr; -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] Added interrupt handler for DMA channel 0, 1 & 2
Added macros for DMA channels 0-12 Added interrupt handlers for DMA 0, 1 & 2 The added IRQs are in accordance with the BCM Peripherals Datasheet and also have been verified with the linux source code for RPi --- c/src/lib/libbsp/arm/raspberrypi/include/irq.h | 17 ++ c/src/lib/libbsp/arm/raspberrypi/irq/irq.c | 45 ++ 2 files changed, 62 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/irq.h b/c/src/lib/libbsp/arm/raspberrypi/include/irq.h index 8436c2d..50616e1 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/irq.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/irq.h @@ -35,6 +35,23 @@ #define BCM2835_INTC_TOTAL_IRQ 64 + 8 +/* DMA Interrupt is routed to IRQ 16 for DMA Channel 0, + IRQ 17 for Channel 1, and so on till IRQ 28 for Channel 12. + */ + +#define BCM2835_IRQ_ID_DMA_CH0 16 +#define BCM2835_IRQ_ID_DMA_CH1 17 +#define BCM2835_IRQ_ID_DMA_CH2 18 +#define BCM2835_IRQ_ID_DMA_CH3 19 +#define BCM2835_IRQ_ID_DMA_CH4 20 +#define BCM2835_IRQ_ID_DMA_CH5 21 +#define BCM2835_IRQ_ID_DMA_CH6 22 +#define BCM2835_IRQ_ID_DMA_CH7 23 +#define BCM2835_IRQ_ID_DMA_CH8 24 +#define BCM2835_IRQ_ID_DMA_CH9 25 +#define BCM2835_IRQ_ID_DMA_CH10 26 +#define BCM2835_IRQ_ID_DMA_CH11 27 +#define BCM2835_IRQ_ID_DMA_CH12 28 #define BCM2835_IRQ_ID_AUX 29 #define BCM2835_IRQ_ID_SPI_SLAVE 43 diff --git a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c index 7b3b2be..3279b35 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c +++ b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c @@ -64,6 +64,21 @@ void bsp_interrupt_dispatch(void) { vector = BCM2835_IRQ_ID_UART; } + /* DMA 0 */ + else if ( BCM2835_REG(BCM2835_IRQ_PENDING1) & BCM2835_BIT(16) ) + { + vector = BCM2835_IRQ_ID_DMA_CH0; + } + /* DMA 1 */ + else if ( BCM2835_REG(BCM2835_IRQ_PENDING1) & BCM2835_BIT(17) ) + { + vector = BCM2835_IRQ_ID_DMA_CH1; + } + /* DMA 2 */ + else if ( BCM2835_REG(BCM2835_IRQ_PENDING1) & BCM2835_BIT(18) ) + { + vector = BCM2835_IRQ_ID_DMA_CH2; + } /* GPIO 0*/ else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(17) ) { @@ -114,6 +129,21 @@ rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) { BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(25); } + /* DMA 0 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH0 ) + { + BCM2835_REG(BCM2835_IRQ_ENABLE1) = BCM2835_BIT(16); + } + /* DMA 1 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH1 ) + { + BCM2835_REG(BCM2835_IRQ_ENABLE1) = BCM2835_BIT(17); + } + /* DMA 2 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH2 ) + { + BCM2835_REG(BCM2835_IRQ_ENABLE1) = BCM2835_BIT(18); + } /* GPIO 0 */ else if ( vector == BCM2835_IRQ_ID_GPIO_0 ) { @@ -164,6 +194,21 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) { BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(25); } + /* DMA 0 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH0 ) + { + BCM2835_REG(BCM2835_IRQ_DISABLE1) = BCM2835_BIT(16); + } + /* DMA 1 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH1 ) + { + BCM2835_REG(BCM2835_IRQ_DISABLE1) = BCM2835_BIT(17); + } + /* DMA 2 */ + else if ( vector == BCM2835_IRQ_ID_DMA_CH2 ) + { + BCM2835_REG(BCM2835_IRQ_DISABLE1) = BCM2835_BIT(18); + } /* GPIO 0 */ else if ( vector == BCM2835_IRQ_ID_GPIO_0 ) { -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] Added interrupt handler for SD card
This is in accordance with the information in the datasheet and has been verified with the linux source code for RPi --- c/src/lib/libbsp/arm/raspberrypi/include/irq.h | 1 + c/src/lib/libbsp/arm/raspberrypi/irq/irq.c | 15 +++ 2 files changed, 16 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/irq.h b/c/src/lib/libbsp/arm/raspberrypi/include/irq.h index 8436c2d..e3b4e7d 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/irq.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/irq.h @@ -51,6 +51,7 @@ #define BCM2835_IRQ_ID_UART 57 +#define BCM2835_IRQ_ID_SDCARD62 #define BCM2835_IRQ_ID_TIMER_0 64 #define BCM2835_IRQ_ID_MAILBOX_0 65 #define BCM2835_IRQ_ID_DOORBELL_066 diff --git a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c index 7b3b2be..c205ef7 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c +++ b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c @@ -91,6 +91,11 @@ void bsp_interrupt_dispatch(void) { vector = BCM2835_IRQ_ID_SPI; } + /* SD CARD */ + else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(30) ) + { + vector = BCM2835_IRQ_ID_SDCARD; + } if ( vector < 255 ) { @@ -144,6 +149,11 @@ rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) { BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(22); } + /* SD CARD */ + else if ( vector == BCM2835_IRQ_ID_SDCARD ) + { + BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(30); + } rtems_interrupt_enable(level); @@ -194,6 +204,11 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) { BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(22); } + /* SD CARD */ + else if ( vector == BCM2835_IRQ_ID_SDCARD ) + { + BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_REG(30); + } rtems_interrupt_enable(level); -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] DMA : Added DMA API for Raspberrypi
Brief API Description rpi_dma_init -> Initializes the channel structure and its members for that particular channel, gets the physical address of the control block structure and installs the interrupt handler. rpi_dma_allocate -> Allocates the channel if it is not busy rpi_dma_setup_dst & rpi_dma_setup_src -> These setup src and dst parameters like dreq, width. Basically they configure the info section of the control block structure of that particular channel. rpi_dma_setup_intr -> These will assign the handler function for channel interrupt. This basically again updates the channel structure with that function. Note : rpi_dma_intr is the callback function for the interrupt controller and calls this function internally. rpi_dma_start -> Here you provide the virtual address, the channel to be used and the width. Internally, it converts the address to physical address and configures the control block for that channel. It flushes and invalidates the cache and writes the physical address of the control block to a particular register corresponding to the channel. rpi_dma_free -> Frees the channel --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 + c/src/lib/libbsp/arm/raspberrypi/include/dma.h | 200 c/src/lib/libbsp/arm/raspberrypi/misc/dma.c| 618 + 3 files changed, 822 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/dma.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/dma.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 4b111ad..5b0e92e 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -51,6 +51,7 @@ include_bsp_HEADERS += include/rpi-gpio.h include_bsp_HEADERS += include/i2c.h include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h +include_bsp_HEADERS += include/dma.h include_bsp_HEADERS += include/vc.h include_bsp_HEADERS += include/rpi-fb.h include_bsp_HEADERS += console/fbcons.h @@ -124,6 +125,9 @@ libbsp_a_SOURCES += console/fb.c libbsp_a_SOURCES += console/fbcons.c libbsp_a_SOURCES += console/outch.c +# DMA +libbsp_a_SOURCES += misc/dma.c + # Mailbox libbsp_a_SOURCES += misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/dma.h b/c/src/lib/libbsp/arm/raspberrypi/include/dma.h new file mode 100644 index 000..c49a575 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/include/dma.h @@ -0,0 +1,200 @@ +/** + * @file + * + * @ingroup raspberrypi_dma + * + * @brief Direct memory access (DMA) support. + */ + +#ifndef LIBBSP_ARM_RASPBERRYPI_DMA_H +#define LIBBSP_ARM_RASPBERRYPI_DMA_H + +#define BCM_DMA_BLOCK_SIZE 512 + +/* DMA0-DMA15 but DMA15 is special */ +#define BCM_DMA_CH_MAX 12 + +/* request CH for any nubmer */ +#define BCM_DMA_CH_INVALID ( -1 ) +#define BCM_DMA_CH_ANY ( -1 ) + +/* Peripheral DREQ Signals (4.2.1.3) */ +#define BCM_DMA_DREQ_NONE 0 +#define BCM_DMA_DREQ_EMMC 11 +#define BCM_DMA_DREQ_SDHOST 13 + +#define BCM_DMA_SAME_ADDR 0 +#define BCM_DMA_INC_ADDR 1 + +#define BCM_DMA_32BIT 0 +#define BCM_DMA_128BIT 1 + +/* + * Defines for converting physical address to VideoCore bus address and back + */ +#define BCM2835_VCBUS_SDRAM_CACHED 0x4000 +#define BCM2835_VCBUS_IO_BASE 0x7E00 +#define BCM2835_VCBUS_SDRAM_UNCACHED 0xC000 + +#ifdef SOC_BCM2836 +#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED +#else +#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_CACHED +#endif +#define BCM2835_ARM_IO_SIZE 0x0100 + +/* + * Convert physical address to VC bus address. Should be used + * when submitting address over mailbox interface + */ +#define PHYS_TO_VCBUS( pa ) ( ( pa ) + BCM2835_VCBUS_SDRAM_BASE ) + +/* Check whether pa bellong top IO window */ +#define BCM2835_ARM_IS_IO( pa ) ( ( ( pa ) >= RPI_PERIPHERAL_BASE ) && \ + ( ( pa ) < RPI_PERIPHERAL_BASE + \ +BCM2835_ARM_IO_SIZE ) ) + +/* + * Convert physical address in IO space to VC bus address. + */ +#define IO_TO_VCBUS( pa ) ( ( ( pa ) - RPI_PERIPHERAL_BASE ) + \ +BCM2835_VCBUS_IO_BASE ) + +/* + * Convert address from VC bus space to physical. Should be used + * when address is returned by VC over mailbox interface. e.g. + * framebuffer base + */ +#define VCBUS_TO_PHYS( vca ) ( ( vca ) & ~( BCM2835_VCBUS_SDRAM_BASE ) ) + +struct bus_dmamap { + void *buffer_begin; + uint32_t buffer_size; +}; + +typedef struct bus_dmamap *bus_dmamap_t; + +/* + * bus_dma_segment_t + * + * Describes a single contiguous DMA transaction. Values + * are suitable for programming into DMA registers. + */ +typedef struct bus_dma_segment { + unsigned int ds_addr; /* DMA address */ + unsigned int ds_len; /* length of transfer */ +} bus_dma_segment_t; + +/* DMA Control Block - 256bit aligned (p.40) */ +struct bcm_dma_cb { + uint32_t
[PATCH 0/5] POSIX Shared Memory Objects
These patches start to add support for POSIX Shared Memory Objects, see http://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html This support aims to improve POSIX compliance. The approach taken is to use the existing score Object as the basis for each shm object, where the Object.Name field directly relates to the name provided to shm_open(). So far the support for shm_open and ftruncate have been included. Support is needed for close() and shm_unlink(). A test is added based on some example code from an OS text book. This test also uses mmap() and munmap() which should be added to support mapping shared memory objects. The ability to specify shared memory management routines has been added. Gedare Bloom (5): posix: add test case for shared memory objects posix: shared memory support posix: implement shm_ftruncate with workspace posix: add user-facing hooks for shm object management psxtests: new test psxshm02 using heap for shm objects cpukit/posix/Makefile.am | 5 + cpukit/posix/include/rtems/posix/config.h | 5 + cpukit/posix/include/rtems/posix/shm.h| 111 +++ cpukit/posix/include/rtems/posix/shmimpl.h| 101 ++ cpukit/posix/preinstall.am| 8 ++ cpukit/posix/src/shm.c| 48 +++ cpukit/posix/src/shmheap.c| 60 cpukit/posix/src/shmopen.c| 194 +- cpukit/posix/src/shmwkspace.c | 67 + cpukit/rtems/src/rtemsobjectgetapiclassname.c | 1 + cpukit/sapi/include/confdefs.h| 39 ++ cpukit/score/include/rtems/score/objectimpl.h | 5 +- cpukit/score/include/rtems/sysinit.h | 1 + testsuites/psxtests/Makefile.am | 4 +- testsuites/psxtests/configure.ac | 2 + testsuites/psxtests/psxshm01/Makefile.am | 22 +++ testsuites/psxtests/psxshm01/init.c | 91 testsuites/psxtests/psxshm01/psxshm01.scn | 0 testsuites/psxtests/psxshm01/system.h | 29 testsuites/psxtests/psxshm02/Makefile.am | 22 +++ testsuites/psxtests/psxshm02/init.c | 91 testsuites/psxtests/psxshm02/psxshm02.scn | 0 testsuites/psxtests/psxshm02/system.h | 38 + testsuites/sptests/spsysinit01/init.c | 17 +++ 24 files changed, 953 insertions(+), 8 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/shm.h create mode 100644 cpukit/posix/include/rtems/posix/shmimpl.h create mode 100644 cpukit/posix/src/shm.c create mode 100644 cpukit/posix/src/shmheap.c create mode 100644 cpukit/posix/src/shmwkspace.c create mode 100644 testsuites/psxtests/psxshm01/Makefile.am create mode 100644 testsuites/psxtests/psxshm01/init.c create mode 100644 testsuites/psxtests/psxshm01/psxshm01.scn create mode 100644 testsuites/psxtests/psxshm01/system.h create mode 100644 testsuites/psxtests/psxshm02/Makefile.am create mode 100644 testsuites/psxtests/psxshm02/init.c create mode 100644 testsuites/psxtests/psxshm02/psxshm02.scn create mode 100644 testsuites/psxtests/psxshm02/system.h -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 2/5] posix: shared memory support
Add POSIX shared memory manager (Shm). --- cpukit/posix/Makefile.am | 3 + cpukit/posix/include/rtems/posix/config.h | 5 + cpukit/posix/include/rtems/posix/shm.h| 61 cpukit/posix/include/rtems/posix/shmimpl.h| 90 cpukit/posix/preinstall.am| 8 ++ cpukit/posix/src/shm.c| 48 +++ cpukit/posix/src/shmopen.c| 197 +- cpukit/rtems/src/rtemsobjectgetapiclassname.c | 1 + cpukit/sapi/include/confdefs.h| 28 cpukit/score/include/rtems/score/objectimpl.h | 5 +- cpukit/score/include/rtems/sysinit.h | 1 + testsuites/psxtests/psxshm01/system.h | 2 +- testsuites/sptests/spsysinit01/init.c | 17 +++ 13 files changed, 459 insertions(+), 7 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/shm.h create mode 100644 cpukit/posix/include/rtems/posix/shmimpl.h create mode 100644 cpukit/posix/src/shm.c diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index c7620df..5490401 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -43,6 +43,8 @@ include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h include_rtems_posix_HEADERS += include/rtems/posix/pthread.h include_rtems_posix_HEADERS += include/rtems/posix/pthreadimpl.h include_rtems_posix_HEADERS += include/rtems/posix/ptimer.h +include_rtems_posix_HEADERS += include/rtems/posix/shm.h +include_rtems_posix_HEADERS += include/rtems/posix/shmimpl.h include_rtems_posix_HEADERS += include/rtems/posix/semaphore.h include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h @@ -100,6 +102,7 @@ libposix_a_SOURCES += src/munlockall.c libposix_a_SOURCES += src/munlock.c libposix_a_SOURCES += src/munmap.c libposix_a_SOURCES += src/posix_madvise.c +libposix_a_SOURCES += src/shm.c libposix_a_SOURCES += src/shmopen.c libposix_a_SOURCES += src/shmunlink.c diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h index 636f1e7..0a1c4e0 100644 --- a/cpukit/posix/include/rtems/posix/config.h +++ b/cpukit/posix/include/rtems/posix/config.h @@ -111,6 +111,11 @@ typedef struct { uint32_tmaximum_rwlocks; /** + * Maximum configured number of POSIX Shared memory objects. + */ + uint32_tmaximum_shms; + + /** * This field contains the maximum number of POSIX API * spinlocks which are configured for this application. */ diff --git a/cpukit/posix/include/rtems/posix/shm.h b/cpukit/posix/include/rtems/posix/shm.h new file mode 100644 index 000..41557b1 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/shm.h @@ -0,0 +1,61 @@ +/** + * @file + * + * @brief Internal Support for POSIX Shared Memory + */ + +/* + * Copyright (c) 2016 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SHM_H +#define _RTEMS_POSIX_SHM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIXShmPrivate POSIX Shared Memory Private Support + * + * @ingroup POSIXAPI + * + * Internal implementation support for POSIX shared memory. + * @{ + */ + +typedef struct { + Objects_Control Object; + Thread_queue_Control Wait_queue; + + int reference_count; + + void*shm_object; + size_t shm_object_size; + void*( *shm_object_allocate )( size_t size ); + void ( *shm_object_free ) ( void *ptr ); + + uid_tuid; + gid_tgid; + mode_t mode; + + time_t atime; + time_t mtime; + time_t ctime; + +} POSIX_Shm_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/posix/include/rtems/posix/shmimpl.h b/cpukit/posix/include/rtems/posix/shmimpl.h new file mode 100644 index 000..2df4bd3 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/shmimpl.h @@ -0,0 +1,90 @@ +/** + * @file + * + * @brief Private Support Information for POSIX Shared Memory + * + */ + +/* + * Copyright (c) 2016 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SHMIMPL_H +#define _RTEMS_POSIX_SHMIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup POSIXShmPrivate + * @{ + */ + +extern Objects_Information _POSIX_Shm_Information; + +RTEMS_INLINE_ROUTINE void _POSIX_Shm_Acquire_critical( + POSIX_Shm_Control *the_shm, + Thread_queue_Context *queue_context
[PATCH 1/5] posix: add test case for shared memory objects
--- testsuites/psxtests/Makefile.am | 4 +- testsuites/psxtests/configure.ac | 1 + testsuites/psxtests/psxshm01/Makefile.am | 22 testsuites/psxtests/psxshm01/init.c | 91 +++ testsuites/psxtests/psxshm01/psxshm01.scn | 0 testsuites/psxtests/psxshm01/system.h | 28 ++ 6 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 testsuites/psxtests/psxshm01/Makefile.am create mode 100644 testsuites/psxtests/psxshm01/init.c create mode 100644 testsuites/psxtests/psxshm01/psxshm01.scn create mode 100644 testsuites/psxtests/psxshm01/system.h diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index a3bffb9..206c450 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -9,8 +9,8 @@ _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ psxcancel psxcancel01 psxclassic01 psxcleanup psxcleanup01 \ psxconcurrency01 psxcond01 psxcond02 psxconfig01 psxenosys \ psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \ -psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \ -psxsignal03 psxsignal04 psxsignal05 psxsignal06 \ +psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxshm01 \ +psxsignal01 psxsignal02 psxsignal03 psxsignal04 psxsignal05 psxsignal06 \ psxspin01 psxspin02 psxsysconf \ psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \ psxintrcritical01 psxstack01 psxstack02 \ diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index be4a21f..e150fc0 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -190,6 +190,7 @@ psxreaddir/Makefile psxrdwrv/Makefile psxrwlock01/Makefile psxsem01/Makefile +psxshm01/Makefile psxsignal01/Makefile psxsignal02/Makefile psxsignal03/Makefile diff --git a/testsuites/psxtests/psxshm01/Makefile.am b/testsuites/psxtests/psxshm01/Makefile.am new file mode 100644 index 000..7082a50 --- /dev/null +++ b/testsuites/psxtests/psxshm01/Makefile.am @@ -0,0 +1,22 @@ + +rtems_tests_PROGRAMS = psxshm01 +psxshm01_SOURCES = init.c system.h + +dist_rtems_tests_DATA = psxshm01.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxshm01_OBJECTS) +LINK_LIBS = $(psxshm01_LDLIBS) + +psxshm01$(EXEEXT): $(psxshm01_OBJECTS) $(psxshm01_DEPENDENCIES) + @rm -f psxshm01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxshm01/init.c b/testsuites/psxtests/psxshm01/init.c new file mode 100644 index 000..24c9b96 --- /dev/null +++ b/testsuites/psxtests/psxshm01/init.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * From http://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CONFIGURE_INIT +#include "system.h" +#include "pritime.h" + +#include + +#include +#include +#include + +const char rtems_test_name[] = "PSX SHM01"; + +#define MAX_LEN 1 +struct region {/* Defines "structure" of shared memory */ + int len; + char buf[MAX_LEN]; +}; + +void *POSIX_Init( + void *argument +) +{ + struct region *p; + int fd; + int err; + char *name = "/shm"; + + TEST_BEGIN(); + + puts( "Init: shm_open" ); + fd = shm_open( name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR ); + if ( fd == -1 ) { +printf ( "Error: %s\n", strerror(errno) ); +rtems_test_assert( fd != -1 ); + } + + puts( "Init: ftruncate" ); + err = ftruncate( fd, sizeof( struct region ) ); + if ( err == -1 ) { +printf ( "Error: %s\n", strerror(errno) ); +rtems_test_assert( err != -1 ); + } + + puts( "Init: mmap" ); + p = mmap( +NULL, +sizeof( struct region ), +PROT_READ | PROT_WRITE, MAP_SHARED, +fd, +0 + ); + rtems_test_assert( p != MAP_FAILED ); + + puts( "Init: write to mapped region" ); + p->len = MAX_LEN; + + puts( "Init: munmap" ); + err = munmap( p, sizeof( struct region ) ); + if ( err == -1 ) { +printf ( "Error: %s\n", strerror(errno) ); +rtems_test_assert( err != -1 ); + } + + puts( "Init: close" ); + err = close( fd ); + if ( err == -1 ) { +printf ( "Error: %s\n", strerror(errno) ); +rtems_test_assert( err != -1 ); + } + + TEST_END(); + + rtems_test_exit(0); + return 0; +} diff --git a/testsuites/psxtests/psxshm01/psxshm01.scn b/testsuites/psxtests/psxshm01/psxshm01.scn new file mode 100644 index 000..e69de29 diff --git a/testsuites/psxtests/psxshm01/system.h b/testsuites/psxtests/psxshm01/system.h new