summaryrefslogtreecommitdiffstats
path: root/c/src/lib
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-25 10:36:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-25 11:02:24 +0200
commitfc1bdb839ef154cc90ff43edf3a5ea21b6b7f789 (patch)
tree0146bd743daf1c944529c303bf7121b7efd244eb /c/src/lib
parentbsp/smdk2410: Move smc.c to bsps (diff)
downloadrtems-fc1bdb839ef154cc90ff43edf3a5ea21b6b7f789.tar.bz2
bsp/raspberrypi: Move source files to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'c/src/lib')
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/Makefile.am8
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/gpio/gpio-interfaces-pi1-rev2.c136
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c335
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c63
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/misc/timer.c48
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/misc/vc.c487
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h518
7 files changed, 4 insertions, 1591 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 83b1e288e1..b4887ceedc 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -76,20 +76,20 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/console/fbcons.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/console/outch.c
# Mailbox
-librtemsbsp_a_SOURCES += misc/mailbox.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/start/mailbox.c
# VideoCore
-librtemsbsp_a_SOURCES += misc/vc.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/start/vc.c
# clock
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/raspberrypi/clock/clockdrv.c
# Timer
-librtemsbsp_a_SOURCES += misc/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/start/timer.c
# GPIO
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/gpio/gpio-support.c
-librtemsbsp_a_SOURCES += gpio/rpi-gpio.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/raspberrypi/gpio/rpi-gpio.c
# RTC
diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/gpio-interfaces-pi1-rev2.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/gpio-interfaces-pi1-rev2.c
deleted file mode 100644
index a958e0dc8e..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/gpio/gpio-interfaces-pi1-rev2.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * @file gpio-interfaces-pi1-rev2.c
- *
- * @ingroup raspberrypi_gpio
- *
- * @brief Raspberry PI 1 rev2 GPIO interface definitions.
- */
-
-/*
- * Copyright (c) 2015 Andre Marques <andre.lousa.marques at gmail.com>
- *
- * 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.
- */
-
-#define JTAG_PIN_COUNT 5
-#define SPI_PIN_COUNT 5
-#define I2C_PIN_COUNT 2
-
-const rtems_gpio_pin_conf jtag_config[JTAG_PIN_COUNT] = {
- { /*arm_tdi */
- .pin_number = 4,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[5]
- },
- { /* arm_trst */
- .pin_number = 22,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[4]
- },
- { /* arm_tdo */
- .pin_number = 24,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[4]
- },
- { /* arm_tck */
- .pin_number = 25,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[4]
- },
- { /* arm_tms */
- .pin_number = 27,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[4]
- }
-};
-
-const rtems_gpio_pin_conf spi_config[SPI_PIN_COUNT] = {
- { /* spi_miso */
- .pin_number = 7,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- },
- { /* spi_mosi */
- .pin_number = 8,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- },
- { /* spi_sclk */
- .pin_number = 9,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- },
- { /* spi_ce_0 */
- .pin_number = 10,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- },
- { /* spi_ce_1 */
- .pin_number = 11,
- .function = BSP_SPECIFIC,
- .pull_mode = NO_PULL_RESISTOR,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- }
-};
-
-const rtems_gpio_pin_conf i2c_config[I2C_PIN_COUNT] = {
- { /* i2c_sda */
- .pin_number = 2,
- .function = BSP_SPECIFIC,
- .pull_mode = PULL_UP,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- },
- { /* i2c_scl */
- .pin_number = 3,
- .function = BSP_SPECIFIC,
- .pull_mode = PULL_UP,
- .interrupt = NULL,
- .output_enabled = FALSE,
- .logic_invert = FALSE,
- .bsp_specific = &alt_func_def[0]
- }
-};
diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c
deleted file mode 100644
index 6c01d62404..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/**
- * @file rpi-gpio.c
- *
- * @ingroup raspberrypi_gpio
- *
- * @brief Support for the Raspberry PI GPIO.
- */
-
-/*
- * Copyright (c) 2014-2015 Andre Marques <andre.lousa.marques at gmail.com>
- *
- * 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.
- */
-
-#include <bsp.h>
-#include <bsp/raspberrypi.h>
-#include <bsp/irq-generic.h>
-#include <bsp/gpio.h>
-#include <bsp/rpi-gpio.h>
-
-#include <stdlib.h>
-
-RTEMS_INTERRUPT_LOCK_DEFINE( static, rtems_gpio_bsp_lock, "rtems_gpio_bsp_lock" );
-
-/* Calculates a bitmask to assign an alternate function to a given pin. */
-#define SELECT_PIN_FUNCTION(fn, pn) (fn << ((pn % 10) * 3))
-
-rtems_gpio_specific_data alt_func_def[] = {
- {.io_function = RPI_ALT_FUNC_0, .pin_data = NULL},
- {.io_function = RPI_ALT_FUNC_1, .pin_data = NULL},
- {.io_function = RPI_ALT_FUNC_2, .pin_data = NULL},
- {.io_function = RPI_ALT_FUNC_3, .pin_data = NULL},
- {.io_function = RPI_ALT_FUNC_4, .pin_data = NULL},
- {.io_function = RPI_ALT_FUNC_5, .pin_data = NULL}
-};
-
-/* Raspberry Pi 1 Revision 2 gpio interface definitions. */
-#include "gpio-interfaces-pi1-rev2.c"
-
-/* Waits a number of CPU cycles. */
-static void arm_delay(uint8_t cycles)
-{
- uint8_t i;
-
- for ( i = 0; i < cycles; ++i ) {
- asm volatile("nop");
- }
-}
-
-static rtems_status_code rpi_select_pin_function(
- uint32_t bank,
- uint32_t pin,
- uint32_t type
-) {
- /* Calculate the pin function select register address. */
- volatile uint32_t *pin_addr = (uint32_t *) BCM2835_GPIO_REGS_BASE +
- (pin / 10);
- uint32_t reg_old;
- uint32_t reg_new;
- rtems_interrupt_lock_context lock_context;
-
- rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context);
- reg_new = reg_old = *pin_addr;
- reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin);
- reg_new |= SELECT_PIN_FUNCTION(type, pin);
- *pin_addr = reg_new;
- rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context);
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_gpio_bsp_multi_set(uint32_t bank, uint32_t bitmask)
-{
- BCM2835_REG(BCM2835_GPIO_GPSET0) = bitmask;
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_gpio_bsp_multi_clear(uint32_t bank, uint32_t bitmask)
-{
- BCM2835_REG(BCM2835_GPIO_GPCLR0) = bitmask;
-
- return RTEMS_SUCCESSFUL;
-}
-
-uint32_t rtems_gpio_bsp_multi_read(uint32_t bank, uint32_t bitmask)
-{
- return (BCM2835_REG(BCM2835_GPIO_GPLEV0) & bitmask);
-}
-
-rtems_status_code rtems_gpio_bsp_set(uint32_t bank, uint32_t pin)
-{
- BCM2835_REG(BCM2835_GPIO_GPSET0) = (1 << pin);
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_gpio_bsp_clear(uint32_t bank, uint32_t pin)
-{
- BCM2835_REG(BCM2835_GPIO_GPCLR0) = (1 << pin);
-
- return RTEMS_SUCCESSFUL;
-}
-
-uint32_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin)
-{
- return (BCM2835_REG(BCM2835_GPIO_GPLEV0) & (1 << pin));
-}
-
-rtems_status_code rtems_gpio_bsp_select_input(
- uint32_t bank,
- uint32_t pin,
- void *bsp_specific
-) {
- return rpi_select_pin_function(bank, pin, RPI_DIGITAL_IN);
-}
-
-rtems_status_code rtems_gpio_bsp_select_output(
- uint32_t bank,
- uint32_t pin,
- void *bsp_specific
-) {
- return rpi_select_pin_function(bank, pin, RPI_DIGITAL_OUT);
-}
-
-rtems_status_code rtems_gpio_bsp_select_specific_io(
- uint32_t bank,
- uint32_t pin,
- uint32_t function,
- void *pin_data
-) {
- return rpi_select_pin_function(bank, pin, function);
-}
-
-rtems_status_code rtems_gpio_bsp_set_resistor_mode(
- uint32_t bank,
- uint32_t pin,
- rtems_gpio_pull_mode mode
-) {
- /* Set control signal. */
- switch ( mode ) {
- case PULL_UP:
- BCM2835_REG(BCM2835_GPIO_GPPUD) = (1 << 1);
- break;
- case PULL_DOWN:
- BCM2835_REG(BCM2835_GPIO_GPPUD) = (1 << 0);
- break;
- case NO_PULL_RESISTOR:
- BCM2835_REG(BCM2835_GPIO_GPPUD) = 0;
- break;
- default:
- return RTEMS_UNSATISFIED;
- }
-
- /* Wait 150 cyles, as per BCM2835 documentation. */
- arm_delay(150);
-
- /* Setup clock for the control signal. */
- BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = (1 << pin);
-
- arm_delay(150);
-
- /* Remove the control signal. */
- BCM2835_REG(BCM2835_GPIO_GPPUD) = 0;
-
- /* Remove the clock. */
- BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = 0;
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_vector_number rtems_gpio_bsp_get_vector(uint32_t bank)
-{
- return BCM2835_IRQ_ID_GPIO_0;
-}
-
-uint32_t rtems_gpio_bsp_interrupt_line(rtems_vector_number vector)
-{
- uint32_t event_status;
-
- /* Retrieve the interrupt event status. */
- event_status = BCM2835_REG(BCM2835_GPIO_GPEDS0);
-
- /* Clear the interrupt line. */
- BCM2835_REG(BCM2835_GPIO_GPEDS0) = event_status;
-
- return event_status;
-}
-
-rtems_status_code rtems_gpio_bsp_enable_interrupt(
- uint32_t bank,
- uint32_t pin,
- rtems_gpio_interrupt interrupt
-) {
- switch ( interrupt ) {
- case FALLING_EDGE:
- /* Enables asynchronous falling edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAFEN0) |= (1 << pin);
- break;
- case RISING_EDGE:
- /* Enables asynchronous rising edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAREN0) |= (1 << pin);
- break;
- case BOTH_EDGES:
- /* Enables asynchronous falling edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAFEN0) |= (1 << pin);
-
- /* Enables asynchronous rising edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAREN0) |= (1 << pin);
- break;
- case LOW_LEVEL:
- /* Enables pin low level detection. */
- BCM2835_REG(BCM2835_GPIO_GPLEN0) |= (1 << pin);
- break;
- case HIGH_LEVEL:
- /* Enables pin high level detection. */
- BCM2835_REG(BCM2835_GPIO_GPHEN0) |= (1 << pin);
- break;
- case BOTH_LEVELS:
- /* Enables pin low level detection. */
- BCM2835_REG(BCM2835_GPIO_GPLEN0) |= (1 << pin);
-
- /* Enables pin high level detection. */
- BCM2835_REG(BCM2835_GPIO_GPHEN0) |= (1 << pin);
- break;
- case NONE:
- default:
- return RTEMS_UNSATISFIED;
- }
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_gpio_bsp_disable_interrupt(
- uint32_t bank,
- uint32_t pin,
- rtems_gpio_interrupt interrupt
-) {
- switch ( interrupt ) {
- case FALLING_EDGE:
- /* Disables asynchronous falling edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAFEN0) &= ~(1 << pin);
- break;
- case RISING_EDGE:
- /* Disables asynchronous rising edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAREN0) &= ~(1 << pin);
- break;
- case BOTH_EDGES:
- /* Disables asynchronous falling edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAFEN0) &= ~(1 << pin);
-
- /* Disables asynchronous rising edge detection. */
- BCM2835_REG(BCM2835_GPIO_GPAREN0) &= ~(1 << pin);
- break;
- case LOW_LEVEL:
- /* Disables pin low level detection. */
- BCM2835_REG(BCM2835_GPIO_GPLEN0) &= ~(1 << pin);
- break;
- case HIGH_LEVEL:
- /* Disables pin high level detection. */
- BCM2835_REG(BCM2835_GPIO_GPHEN0) &= ~(1 << pin);
- break;
- case BOTH_LEVELS:
- /* Disables pin low level detection. */
- BCM2835_REG(BCM2835_GPIO_GPLEN0) &= ~(1 << pin);
-
- /* Disables pin high level detection. */
- BCM2835_REG(BCM2835_GPIO_GPHEN0) &= ~(1 << pin);
- break;
- case NONE:
- default:
- return RTEMS_UNSATISFIED;
- }
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rpi_gpio_select_jtag(void)
-{
- return rtems_gpio_multi_select(jtag_config, JTAG_PIN_COUNT);
-}
-
-rtems_status_code rpi_gpio_select_spi(void)
-{
- return rtems_gpio_multi_select(spi_config, SPI_PIN_COUNT);
-}
-
-rtems_status_code rpi_gpio_select_i2c(void)
-{
- return rtems_gpio_multi_select(i2c_config, I2C_PIN_COUNT);
-}
-
-rtems_status_code rtems_gpio_bsp_multi_select(
- rtems_gpio_multiple_pin_select *pins,
- uint32_t pin_count,
- uint32_t select_bank
-) {
- uint32_t register_address;
- uint32_t select_register;
- uint8_t i;
-
- register_address = BCM2835_GPIO_REGS_BASE + (select_bank * 0x04);
-
- select_register = BCM2835_REG(register_address);
-
- for ( i = 0; i < pin_count; ++i ) {
- if ( pins[i].function == DIGITAL_INPUT ) {
- select_register &=
- ~SELECT_PIN_FUNCTION(RPI_DIGITAL_IN, pins[i].pin_number);
- }
- else if ( pins[i].function == DIGITAL_OUTPUT ) {
- select_register |=
- SELECT_PIN_FUNCTION(RPI_DIGITAL_OUT, pins[i].pin_number);
- }
- else { /* BSP_SPECIFIC function. */
- select_register |=
- SELECT_PIN_FUNCTION(pins[i].io_function, pins[i].pin_number);
- }
- }
-
- BCM2835_REG(register_address) = select_register;
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_gpio_bsp_specific_group_operation(
- uint32_t bank,
- uint32_t *pins,
- uint32_t pin_count,
- void *arg
-) {
- return RTEMS_NOT_DEFINED;
-}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c
deleted file mode 100644
index 8196781ee5..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * @file
- *
- * @ingroup raspberrypi
- *
- * @brief mailbox support.
- */
-/*
- * Copyright (c) 2015 Yang Qiao
- *
- * 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
- *
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <bsp.h>
-#include <bsp/raspberrypi.h>
-#include <bsp/mailbox.h>
-
-#define BCM2835_MBOX_DATA_MASK( data ) ( data & 0xFFFFFFF0U )
-#define BCM2835_MBOX_CHANNEL_MASK( data ) ( data & 0xFU )
-
-static inline bool bcm2835_mailbox_is_empty( void )
-{
- return ( BCM2835_REG( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_EMPTY );
-}
-
-static inline bool bcm2835_mailbox_is_full( void )
-{
- return ( BCM2835_REG( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_FULL );
-}
-
-unsigned int raspberrypi_mailbox_read( unsigned int channel )
-{
- unsigned int raw;
- unsigned int read_channel;
-
- while ( 1 ) {
- while ( bcm2835_mailbox_is_empty() ) ;
-
- raw = BCM2835_REG( BCM2835_MBOX_READ );
- read_channel = BCM2835_MBOX_CHANNEL_MASK( raw );
-
- if ( read_channel == channel )
- return BCM2835_MBOX_DATA_MASK( raw );
- }
-}
-
-void raspberrypi_mailbox_write(
- unsigned int channel,
- unsigned int data
-)
-{
- while ( bcm2835_mailbox_is_full() ) ;
-
- BCM2835_REG( BCM2835_MBOX_WRITE ) =
- BCM2835_MBOX_DATA_MASK( data ) |
- BCM2835_MBOX_CHANNEL_MASK( channel );
-}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c b/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c
deleted file mode 100644
index f52ecb3a26..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @file
- *
- * @ingroup raspberrypi
- *
- * @brief Benchmark timer support.
- */
-
-/*
- * Copyright (c) 2013 by Alan Cudmore
- *
- * 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
- *
- */
-
-#include <bsp.h>
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <bsp/raspberrypi.h>
-
-static bool benchmark_timer_find_average_overhead = false;
-
-static uint64_t benchmark_timer_base;
-
-void benchmark_timer_initialize( void )
-{
- benchmark_timer_base = BCM2835_REG( BCM2835_GPU_TIMER_CLO );
-}
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- uint32_t delta = BCM2835_REG( BCM2835_GPU_TIMER_CLO ) - benchmark_timer_base;
-
- if ( benchmark_timer_find_average_overhead ) {
- return delta;
- } else {
- return BCM2835_REG( BCM2835_GPU_TIMER_CLO );
- }
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(
- bool find_average_overhead )
-{
- benchmark_timer_find_average_overhead = find_average_overhead;
-}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
deleted file mode 100644
index 249ea1e9a2..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/**
- * @file
- *
- * @ingroup raspberrypi_vc
- *
- * @brief video core support.
- *
- */
-
-/*
- * Copyright (c) 2015 Yang Qiao
- *
- * 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
- *
- */
-#include <pthread.h>
-
-#include <bsp.h>
-#include <bsp/raspberrypi.h>
-#include <bsp/mailbox.h>
-#include <bsp/vc.h>
-#include <libcpu/arm-cp15.h>
-#include "vc_defines.h"
-
-#if ( RPI_L2_CACHE_ENABLE == 1 )
- #define BCM2835_VC_MEMORY_MAPPING 0x40000000
-#else
- #define BCM2835_VC_MEMORY_MAPPING 0xC0000000
-#endif
-
-#define BCM2835_VC_MEMORY_MAPPING_MASK 0x3fffffff
-
-static inline bool bcm2835_mailbox_buffer_suceeded(
- const bcm2835_mbox_buf_hdr *hdr )
-{
- RTEMS_COMPILER_MEMORY_BARRIER();
- return ( hdr->buf_code == BCM2835_MBOX_BUF_CODE_REQUEST_SUCCEED );
-}
-
-static inline int bcm2835_mailbox_send_read_buffer( void *buf )
-{
- RTEMS_COMPILER_MEMORY_BARRIER();
- raspberrypi_mailbox_write( BCM2835_MBOX_CHANNEL_PROP_AVC,
- (unsigned int) buf + BCM2835_VC_MEMORY_MAPPING );
- raspberrypi_mailbox_read( BCM2835_MBOX_CHANNEL_PROP_AVC );
- RTEMS_COMPILER_MEMORY_BARRIER();
- return 0;
-}
-
-/*
- * When cache is enabled then content of buffer exchanged
- * with VideoCore has to be propagated through ARM11/Cortex-A7
- * caches
- */
-static inline void bcm2835_mailbox_buffer_flush_and_invalidate(
- void *buf,
- size_t size
-)
-{
- rtems_cache_flush_multiple_data_lines( buf, size );
- rtems_cache_invalidate_multiple_data_lines( buf, size );
-}
-
-#define BCM2835_MBOX_VAL_LENGTH_MASK( _val_len ) \
- ( _val_len & ( ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE ) )
-
-int bcm2835_mailbox_get_display_size(
- bcm2835_get_display_size_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_display_size get_display_size;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_display_size,
- BCM2835_MAILBOX_TAG_GET_DISPLAY_SIZE );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->width = buffer.get_display_size.body.resp.width;
- _entries->height = buffer.get_display_size.body.resp.height;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_display_size ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_init_frame_buffer(
- bcm2835_init_frame_buffer_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_display_size set_display_size;
- bcm2835_mbox_tag_virtual_size set_virtual_size;
- bcm2835_mbox_tag_depth set_depth;
- bcm2835_mbox_tag_pixel_order set_pixel_order;
- bcm2835_mbox_tag_alpha_mode set_alpha_mode;
- bcm2835_mbox_tag_virtual_offset set_virtual_offset;
- bcm2835_mbox_tag_overscan set_overscan;
- bcm2835_mbox_tag_allocate_buffer allocate_buffer;
- bcm2835_mbox_tag_get_pitch get_pitch;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG( &buffer.set_display_size,
- BCM2835_MAILBOX_TAG_SET_DISPLAY_SIZE );
- buffer.set_display_size.body.req.width = _entries->xres;
- buffer.set_display_size.body.req.height = _entries->yres;
- BCM2835_MBOX_INIT_TAG( &buffer.set_virtual_size,
- BCM2835_MAILBOX_TAG_SET_VIRTUAL_SIZE );
- buffer.set_virtual_size.body.req.vwidth = _entries->xvirt;
- buffer.set_virtual_size.body.req.vheight = _entries->yvirt;
- BCM2835_MBOX_INIT_TAG( &buffer.set_depth,
- BCM2835_MAILBOX_TAG_SET_DEPTH );
- buffer.set_depth.body.req.depth = _entries->depth;
- BCM2835_MBOX_INIT_TAG( &buffer.set_pixel_order,
- BCM2835_MAILBOX_TAG_SET_PIXEL_ORDER );
- buffer.set_pixel_order.body.req.pixel_order = _entries->pixel_order;
- BCM2835_MBOX_INIT_TAG( &buffer.set_alpha_mode,
- BCM2835_MAILBOX_TAG_SET_ALPHA_MODE );
- buffer.set_alpha_mode.body.req.alpha_mode = _entries->alpha_mode;
- BCM2835_MBOX_INIT_TAG( &buffer.set_virtual_offset,
- BCM2835_MAILBOX_TAG_SET_VIRTUAL_OFFSET );
- buffer.set_virtual_offset.body.req.voffset_x = _entries->voffset_x;
- buffer.set_virtual_offset.body.req.voffset_x = _entries->voffset_y;
- BCM2835_MBOX_INIT_TAG( &buffer.set_overscan,
- BCM2835_MAILBOX_TAG_SET_OVERSCAN );
- buffer.set_overscan.body.req.overscan_top = _entries->overscan_top;
- buffer.set_overscan.body.req.overscan_bottom = _entries->overscan_bottom;
- buffer.set_overscan.body.req.overscan_left = _entries->overscan_left;
- buffer.set_overscan.body.req.overscan_right = _entries->overscan_right;
- BCM2835_MBOX_INIT_TAG( &buffer.allocate_buffer,
- BCM2835_MAILBOX_TAG_ALLOCATE_BUFFER );
- buffer.allocate_buffer.body.req.align = 0x100;
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_pitch,
- BCM2835_MAILBOX_TAG_GET_PITCH );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->xres = buffer.set_display_size.body.resp.width;
- _entries->yres = buffer.set_display_size.body.resp.height;
- _entries->xvirt = buffer.set_virtual_size.body.resp.vwidth;
- _entries->yvirt = buffer.set_virtual_size.body.resp.vheight;
- _entries->depth = buffer.set_depth.body.resp.depth;
- _entries->base = buffer.allocate_buffer.body.resp.base;
- _entries->base &= BCM2835_VC_MEMORY_MAPPING_MASK;
- _entries->size = buffer.allocate_buffer.body.resp.size;
- _entries->pixel_order = buffer.set_pixel_order.body.resp.pixel_order;
- _entries->alpha_mode = buffer.set_alpha_mode.body.resp.alpha_mode;
- _entries->voffset_x = buffer.set_virtual_offset.body.resp.voffset_x;
- _entries->voffset_y = buffer.set_virtual_offset.body.resp.voffset_y;
- _entries->overscan_left = buffer.set_overscan.body.resp.overscan_left;
- _entries->overscan_right = buffer.set_overscan.body.resp.overscan_right;
- _entries->overscan_top = buffer.set_overscan.body.resp.overscan_top;
- _entries->overscan_bottom = buffer.set_overscan.body.resp.overscan_bottom;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.allocate_buffer ) )
- return -3;
-
- if ( _entries->base < 0x100000 )
- return -4;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_pitch( bcm2835_get_pitch_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_pitch get_pitch;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_pitch,
- BCM2835_MAILBOX_TAG_GET_PITCH );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->pitch = buffer.get_pitch.body.resp.pitch;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_pitch ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries )
-{
- int i;
-
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_cmd_line get_cmd_line;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_cmd_line,
- BCM2835_MAILBOX_TAG_GET_CMD_LINE );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- for ( i = 0;
- i < BCM2835_MBOX_VAL_LENGTH_MASK( buffer.get_cmd_line.tag_hdr.val_len );
- ++i ) {
- _entries->cmdline[ i ] = buffer.get_cmd_line.body.resp.cmdline[ i ];
- }
-
- _entries->cmdline[ i ] = '\0';
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_cmd_line ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_power_state get_power_state;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- 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 BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_power_state set_power_state;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG( &buffer.set_power_state,
- BCM2835_MAILBOX_TAG_SET_POWER_STATE );
- buffer.set_power_state.body.req.dev_id = _entries->dev_id;
- buffer.set_power_state.body.req.state = _entries->state;
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->dev_id = buffer.set_power_state.body.resp.dev_id;
- _entries->state = buffer.set_power_state.body.resp.state;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_arm_memory( bcm2835_get_arm_memory_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_arm_memory get_arm_memory;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_arm_memory,
- BCM2835_MAILBOX_TAG_GET_ARM_MEMORY );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->base = buffer.get_arm_memory.body.resp.base;
- _entries->size = buffer.get_arm_memory.body.resp.size;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_arm_memory ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_vc_memory( bcm2835_get_vc_memory_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_vc_memory get_vc_memory;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_vc_memory,
- BCM2835_MAILBOX_TAG_GET_VC_MEMORY );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->base = buffer.get_vc_memory.body.resp.base;
- _entries->size = buffer.get_vc_memory.body.resp.size;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_vc_memory ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_firmware_revision(
- bcm2835_mailbox_get_fw_rev_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_fw_rev get_fw_rev;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_fw_rev,
- BCM2835_MAILBOX_TAG_FIRMWARE_REVISION );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->fw_rev = buffer.get_fw_rev.body.resp.rev;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_fw_rev ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_board_spec get_board_model;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_model,
- BCM2835_MAILBOX_TAG_GET_BOARD_MODEL );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->spec = buffer.get_board_model.body.resp.spec;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_board_model ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_board_revision(
- bcm2835_get_board_spec_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_board_spec get_board_revision;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- BCM2835_MBOX_INIT_BUF( &buffer );
- BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_revision,
- BCM2835_MAILBOX_TAG_GET_BOARD_VERSION );
- bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( buffer ) );
-
- if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
- return -1;
-
- _entries->spec = buffer.get_board_revision.body.resp.spec;
-
- if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
- return -2;
-
- if ( !BCM2835_MBOX_TAG_REPLY_IS_SET( &buffer.get_board_revision ) )
- return -3;
-
- return 0;
-}
-
-int bcm2835_mailbox_get_board_serial(
- bcm2835_get_board_serial_entries *_entries )
-{
- struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_board_serial get_board_serial;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- 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_ALIGN_ATTRIBUTE {
- bcm2835_mbox_buf_hdr hdr;
- bcm2835_mbox_tag_get_clock_rate get_clock_rate;
- uint32_t end_tag;
- uint32_t padding_reserve[16];
- } buffer;
- 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
deleted file mode 100644
index 857305bf92..0000000000
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
+++ /dev/null
@@ -1,518 +0,0 @@
-/**
- * @file
- *
- * @ingroup raspberrypi_vc
- *
- * @brief video core support.
- *
- */
-
-/*
- * Copyright (c) 2015 Yang Qiao
- *
- * 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 LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H
-#define LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H
-
-#include <string.h>
-
-/**
- * @defgroup raspberrypi_vc Register Definitions
- *
- * @ingroup arm_raspberrypi
- *
- * @brief Register Definitions
- *
- * @{
- */
-
-/**
- * @name Mailbox Property tags (ARM <-> VC)
- *
- * @{
- */
-
-#define BCM2835_MBOX_BUF_CODE_PROCESS_REQUEST 0x00000000
-#define BCM2835_MBOX_BUF_CODE_REQUEST_SUCCEED 0x80000000
-#define BCM2835_MBOX_BUF_CODE_REQUEST_PARSING_ERROR 0x80000001
-#define BCM2835_MBOX_TAG_VAL_LEN_REQUEST 0x00000000
-#define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE 0x80000000
-
-/**
- * @brief Buffer Header
- *
- * All message buffers should start with this header, called 'hdr'.
- * Then it should be followed by a list of tags.
- * An additional empty tag should be added at the end, called 'end_tag'
- *
- */
-typedef struct {
- /**
- * @brief Buffer Size
- *
- * The size of whole structure including the header(size and code),
- * tags, end tag and padding.
- */
- uint32_t buf_size;
-
- /**
- * @brief Buffer Code
- *
- * The code indicate the status of operation.
- * Use function BCM2835_MAILBOX_BUFFER_IS_SUCCEED(bcm2835_mailbox_buffer*)
- * to check if the operation is succeed
- */
- uint32_t buf_code;
-} bcm2835_mbox_buf_hdr;
-
-/**
- * @brief Tag Header
- *
- * Tag is used for getting/testing/setting an property.
- * All tags should start with this header.
- * Then it should be followed by a data buffer for request and response.
- *
- */
-typedef struct {
- /**
- * @brief Property Tag ID
- */
- uint32_t tag;
- /**
- * @brief The size of request qnd responce buffer
- */
- uint32_t val_buf_size;
- /**
- * @brief The size of response buffer set by videocore.
- *
- * upper bit reserved for request/response indicator
- */
- uint32_t val_len;
-} bcm2835_mbox_tag_hdr;
-
-#define BCM2835_MBOX_TAG_REPLY_IS_SET( _t_ ) \
- ( ( _t_ )->tag_hdr.val_len & 0x80000000 )
-
-#define BCM2835_MBOX_INIT_BUF( _m_ ) { \
- memset( ( _m_ ), 0, sizeof( *( _m_ ) ) ); \
- ( _m_ )->hdr.buf_size = (void *)&(( _m_ )->end_tag) + 4 - (void *)( _m_ ); \
- ( _m_ )->hdr.buf_code = BCM2835_MBOX_BUF_CODE_PROCESS_REQUEST; \
- ( _m_ )->end_tag = 0; \
-}
-
-#define BCM2835_MBOX_INIT_TAG( _t_, _id_ ) { \
- ( _t_ )->tag_hdr.tag = _id_; \
- ( _t_ )->tag_hdr.val_buf_size = sizeof( ( _t_ )->body ); \
- ( _t_ )->tag_hdr.val_len = sizeof( ( _t_ )->body.req ); \
-}
-
-#define BCM2835_MBOX_INIT_TAG_NO_REQ( _t_, _id_ ) { \
- ( _t_ )->tag_hdr.tag = _id_; \
- ( _t_ )->tag_hdr.val_buf_size = sizeof( ( _t_ )->body ); \
- ( _t_ )->tag_hdr.val_len = 0; \
-}
-
-/*
- * Mailbox buffers has to be aligned to 16 bytes because
- * 4 LSB bits of the BCM2835_MBOX_WRITE and BCM2835_MBOX_READ
- * registers are used to pass channel number.
- *
- * But there is another requirement for buffer allocation
- * as well when interface is called after cache is enabled.
- * The buffer should not share cache line with another variable
- * which can be updated during data exchange with VideoCore.
- * If cache is filled to satisfy another variable update
- * during VideoCore output is stored into main memory then
- * part of received data can be lost.
- *
- * Cache line length is 64 bytes for RPi2 Cortex-A7 data cache
- * so align buffers to this value.
- */
-#define BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE __attribute__( ( aligned( 64 ) ) )
-
-/* Video Core */
-#define BCM2835_MAILBOX_TAG_FIRMWARE_REVISION 0x00000001
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- } req;
- struct {
- uint32_t rev;
- } resp;
- } body;
-} bcm2835_mbox_tag_get_fw_rev;
-
-/* Hardware */
-#define BCM2835_MAILBOX_TAG_GET_BOARD_MODEL 0x00010001
-#define BCM2835_MAILBOX_TAG_GET_BOARD_VERSION 0x00010002
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- } req;
- struct {
- uint32_t spec;
- } resp;
- } body;
-} bcm2835_mbox_tag_get_board_spec;
-
-#if (BSP_IS_RPI2 == 1)
-#define BCM2836_MAILBOX_BOARD_V_2_B 0x4
-#else
-#define BCM2835_MAILBOX_BOARD_V_B_I2C0_2 0x2
-#define BCM2835_MAILBOX_BOARD_V_B_I2C0_3 0x3
-#define BCM2835_MAILBOX_BOARD_V_B_I2C1_4 0x4
-#define BCM2835_MAILBOX_BOARD_V_B_I2C1_5 0x5
-#define BCM2835_MAILBOX_BOARD_V_B_I2C1_6 0x6
-#define BCM2835_MAILBOX_BOARD_V_A_7 0x7
-#define BCM2835_MAILBOX_BOARD_V_A_8 0x8
-#define BCM2835_MAILBOX_BOARD_V_A_9 0x9
-#define BCM2835_MAILBOX_BOARD_V_B_REV2_d 0xd
-#define BCM2835_MAILBOX_BOARD_V_B_REV2_e 0xe
-#define BCM2835_MAILBOX_BOARD_V_B_REV2_f 0xf
-#define BCM2835_MAILBOX_BOARD_V_B_PLUS 0x10
-#define BCM2835_MAILBOX_BOARD_V_CM 0x11
-#define BCM2835_MAILBOX_BOARD_V_A_PLUS 0x12
-#endif
-
-#define BCM2835_MAILBOX_TAG_GET_BOARD_MAC 0x00010003
-#define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL 0x00010004
-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;
- union {
- struct {
- } req;
- struct {
- uint32_t base;
- uint32_t size;
- } resp;
- } body;
-} bcm2835_mbox_tag_get_arm_memory;
-
-#define BCM2835_MAILBOX_TAG_GET_VC_MEMORY 0x00010006
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- } req;
- struct {
- uint32_t base;
- uint32_t size;
- } resp;
- } body;
-} 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_LINE 0x00050001
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- } req;
- struct {
- uint8_t cmdline[ 1024 ];
- } resp;
- } body;
-} bcm2835_mbox_tag_get_cmd_line;
-
-/* Shared resource management */
-#define BCM2835_MAILBOX_TAG_GET_DMA_CHANNELS 0x00060001
-
-/* Power */
-#define BCM2835_MAILBOX_POWER_UDID_SD_Card 0x00000000
-#define BCM2835_MAILBOX_POWER_UDID_UART0 0x00000001
-#define BCM2835_MAILBOX_POWER_UDID_UART1 0x00000002
-#define BCM2835_MAILBOX_POWER_UDID_USB_HCD 0x00000003
-#define BCM2835_MAILBOX_POWER_UDID_I2C0 0x00000004
-#define BCM2835_MAILBOX_POWER_UDID_I2C1 0x00000005
-#define BCM2835_MAILBOX_POWER_UDID_I2C2 0x00000006
-#define BCM2835_MAILBOX_POWER_UDID_SPI 0x00000007
-#define BCM2835_MAILBOX_POWER_UDID_CCP2TX 0x00000008
-
-#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)
-
-#define BCM2835_MAILBOX_TAG_GET_TIMING 0x00020002
-#define BCM2835_MAILBOX_TAG_SET_POWER_STATE 0x00028001
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t dev_id;
- uint32_t state;
- } req;
- struct {
- uint32_t dev_id;
- uint32_t state;
- } resp;
- } body;
-} bcm2835_mbox_tag_power_state;
-
-#ifndef BCM2835_MAILBOX_SET_POWER_STATE_REQ_ON
-/* Value is defined as a part of public VideoCore API */
-#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_ON (1 << 0)
-#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_WAIT (1 << 1)
-#endif
-
-/* Clocks */
-#define BCM2835_MAILBOX_UCID_CLOCK_RESERVED 0x000000000
-#define BCM2835_MAILBOX_UCID_CLOCK_EMMC 0x000000001
-#define BCM2835_MAILBOX_UCID_CLOCK_UART 0x000000002
-#define BCM2835_MAILBOX_UCID_CLOCK_ARM 0x000000003
-#define BCM2835_MAILBOX_UCID_CLOCK_CORE 0x000000004
-#define BCM2835_MAILBOX_UCID_CLOCK_V3D 0x000000005
-#define BCM2835_MAILBOX_UCID_CLOCK_H264 0x000000006
-#define BCM2835_MAILBOX_UCID_CLOCK_ISP 0x000000007
-#define BCM2835_MAILBOX_UCID_CLOCK_SDRAM 0x000000008
-#define BCM2835_MAILBOX_UCID_CLOCK_PIXEL 0x000000009
-#define BCM2835_MAILBOX_UCID_CLOCK_PWM 0x00000000a
-
-#define BCM2835_MAILBOX_TAG_GET_CLOCK_STATE 0x00030001
-#define BCM2835_MAILBOX_TAG_SET_CLOCK_STATE 0x00038001
-#define BCM2835_MAILBOX_TAG_GET_CLOCK_RATE 0x00030002
-#define BCM2835_MAILBOX_TAG_SET_CLOCK_RATE 0x00038002
-#define BCM2835_MAILBOX_TAG_GET_MAX_CLOCK_RATE 0x00030004
-#define BCM2835_MAILBOX_TAG_GET_MIN_CLOCK_RATE 0x00030007
-#define BCM2835_MAILBOX_TAG_GET_TRUBO 0x00030009
-#define BCM2835_MAILBOX_TAG_SET_TURBO 0x00038009
-
-#define BCM2835_MAILBOX_TAG_GET_DOMAIN_STATE 0x00030030
-#define BCM2835_MAILBOX_TAG_SET_DOMAIN_STATE 0x00038030
-
-/* Voltage */
-#define BCM2835_MAILBOX_VOLTAGE_RESERVED_UVID 0x000000000
-#define BCM2835_MAILBOX_VOLTAGE_CORE_UVID 0x000000001
-#define BCM2835_MAILBOX_VOLTAGE_SDRAM_C_UVID 0x000000002
-#define BCM2835_MAILBOX_VOLTAGE_SDRAM_P_UVID 0x000000003
-#define BCM2835_MAILBOX_VOLTAGE_SDRAM_I_UVID 0x000000004
-
-#define BCM2835_MAILBOX_TAG_GET_VOLTAGE 0x00030003
-#define BCM2835_MAILBOX_TAG_SET_VOLTAGE 0x00038003
-#define BCM2835_MAILBOX_TAG_GET_MAX_VOLTAGE 0x00030005
-#define BCM2835_MAILBOX_TAG_GET_MIN_VOLTAGE 0x00030008
-#define BCM2835_MAILBOX_TAG_GET_TEMPERATURE 0x00030006
-#define BCM2835_MAILBOX_TAG_GET_MAX_TEMPERATURE 0x0003000a
-
-/* Memory */
-#define BCM2835_MAILBOX_TAG_ALLOCATE_MEMORY 0x0003000c
-#define BCM2835_MAILBOX_TAG_LOCK_MEMORY 0x0003000d
-#define BCM2835_MAILBOX_TAG_UNLOCK_MEMORY 0x0003000e
-#define BCM2835_MAILBOX_TAG_RELEASE_MEMORY 0x0003000f
-#define BCM2835_MAILBOX_TAG_EXECUTE_CODE 0x00030010
-#define BCM2835_MAILBOX_TAG_GET_DISPMANX_RESOURCE_MEM_HANDLE 0x00030014
-
-#define BCM2835_MAILBOX_TAG_GET_EDID_BLOCK 0x00030020
-
-/* Framebuffer */
-#define BCM2835_MAILBOX_TAG_ALLOCATE_BUFFER 0x00040001
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t align;
- } req;
- struct {
- uint32_t base;
- uint32_t size;
- } resp;
- } body;
-} bcm2835_mbox_tag_allocate_buffer;
-
-#define BCM2835_MAILBOX_TAG_RELEASE_BUFFER 0x00048001
-
-#define BCM2835_MAILBOX_TAG_BLANK_SCREEN 0x00040002
-
-#define BCM2835_MAILBOX_TAG_GET_DISPLAY_SIZE 0x00040003
-#define BCM2835_MAILBOX_TAG_TEST_DISPLAY_SIZE 0x00044003
-#define BCM2835_MAILBOX_TAG_SET_DISPLAY_SIZE 0x00048003
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t width;
- uint32_t height;
- } req;
- struct {
- uint32_t width;
- uint32_t height;
- } resp;
- } body;
-} bcm2835_mbox_tag_display_size;
-
-#define BCM2835_MAILBOX_TAG_GET_VIRTUAL_SIZE 0x00040004
-#define BCM2835_MAILBOX_TAG_TEST_VIRTUAL_SIZE 0x00044004
-#define BCM2835_MAILBOX_TAG_SET_VIRTUAL_SIZE 0x00048004
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t vwidth;
- uint32_t vheight;
- } req;
- struct {
- uint32_t vwidth;
- uint32_t vheight;
- } resp;
- } body;
-} bcm2835_mbox_tag_virtual_size;
-
-#define BCM2835_MAILBOX_TAG_GET_DEPTH 0x00040005
-#define BCM2835_MAILBOX_TAG_TEST_DEPTH 0x00044005
-#define BCM2835_MAILBOX_TAG_SET_DEPTH 0x00048005
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t depth;
- } req;
- struct {
- uint32_t depth;
- } resp;
- } body;
-} bcm2835_mbox_tag_depth;
-
-#define BCM2835_MAILBOX_TAG_GET_PIXEL_ORDER 0x00040006
-#define BCM2835_MAILBOX_TAG_TEST_PIXEL_ORDER 0x00044006
-#define BCM2835_MAILBOX_TAG_SET_PIXEL_ORDER 0x00048006
-
-#define BCM2835_MAILBOX_PIXEL_ORDER_BGR 0
-#define BCM2835_MAILBOX_PIXEL_ORDER_RGB 1
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t pixel_order;
- } req;
- struct {
- uint32_t pixel_order;
- } resp;
- } body;
-} bcm2835_mbox_tag_pixel_order;
-
-#define BCM2835_MAILBOX_TAG_GET_ALPHA_MODE 0x00040007
-#define BCM2835_MAILBOX_TAG_TEST_ALPHA_MODE 0x00044007
-#define BCM2835_MAILBOX_TAG_SET_ALPHA_MODE 0x00048007
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t alpha_mode;
- } req;
- struct {
- uint32_t alpha_mode;
- } resp;
- } body;
-} bcm2835_mbox_tag_alpha_mode;
-
-#define BCM2835_MAILBOX_ALPHA_MODE_0_OPAQUE 0
-#define BCM2835_MAILBOX_ALPHA_MODE_0_TRANSPARENT 1
-#define BCM2835_MAILBOX_ALPHA_MODE_IGNORED 2
-
-#define BCM2835_MAILBOX_TAG_GET_PITCH 0x00040008
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- } req;
- struct {
- uint32_t pitch;
- } resp;
- } body;
-} bcm2835_mbox_tag_get_pitch;
-
-#define BCM2835_MAILBOX_TAG_GET_VIRTUAL_OFFSET 0x00040009
-#define BCM2835_MAILBOX_TAG_TEST_VIRTUAL_OFFSET 0x00044009
-#define BCM2835_MAILBOX_TAG_SET_VIRTUAL_OFFSET 0x00048009
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t voffset_x;
- uint32_t voffset_y;
- } req;
- struct {
- uint32_t voffset_x;
- uint32_t voffset_y;
- } resp;
- } body;
-} bcm2835_mbox_tag_virtual_offset;
-
-#define BCM2835_MAILBOX_TAG_GET_OVERSCAN 0x0004000a
-#define BCM2835_MAILBOX_TAG_TEST_OVERSCAN 0x0004400a
-#define BCM2835_MAILBOX_TAG_SET_OVERSCAN 0x0004800a
-typedef struct {
- bcm2835_mbox_tag_hdr tag_hdr;
- union {
- struct {
- uint32_t overscan_top;
- uint32_t overscan_bottom;
- uint32_t overscan_left;
- uint32_t overscan_right;
- } req;
- struct {
- uint32_t overscan_top;
- uint32_t overscan_bottom;
- uint32_t overscan_left;
- uint32_t overscan_right;
- } resp;
- } body;
-} bcm2835_mbox_tag_overscan;
-
-#define BCM2835_MAILBOX_TAG_GET_PALETTE 0x0004000b
-#define BCM2835_MAILBOX_TAG_TEST_PALETTE 0x0004400b
-#define BCM2835_MAILBOX_TAG_SET_PALETTE 0x0004800b
-#define BCM2835_MAILBOX_TAG_SET_CURSOR_INFO 0x00008011
-#define BCM2835_MAILBOX_TAG_SET_CURSOR_STATE 0x00008010
-
-/** @} */
-
-/** @} */
-
-#endif /* LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H */