Skip to content

Commit

Permalink
USB: update section handling for USB Memory Pool (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloradCvjetkovic authored Jun 4, 2024
1 parent e070216 commit d3d7611
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 38 deletions.
44 changes: 6 additions & 38 deletions Components/USB/Source/usbh_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "usbh_config.h"

#include "usbh_section.h"

/*------------------------------------------------------------------------------
* USB Host Configuration calculated macros
*----------------------------------------------------------------------------*/
Expand All @@ -23,40 +25,6 @@
#define USBHn_DRIVER_(n) Driver_USBH##n
#define USBHn_DRIVER(n) USBHn_DRIVER_(n)

#define USBHn_HC_MEM_POOL_SECTION_(x) __attribute__((section(x)))

#ifdef USBH0_HC_NUM
#if (USBH0_HC_MEM_POOL_RELOC == 1)
#define USBH0_HC_MEM_POOL_SECTION(x) USBHn_HC_MEM_POOL_SECTION_(x)
#else
#define USBH0_HC_MEM_POOL_SECTION(x)
#endif
#endif

#ifdef USBH1_HC_NUM
#if (USBH1_HC_MEM_POOL_RELOC == 1)
#define USBH1_HC_MEM_POOL_SECTION(x) USBHn_HC_MEM_POOL_SECTION_(x)
#else
#define USBH1_HC_MEM_POOL_SECTION(x)
#endif
#endif

#ifdef USBH2_HC_NUM
#if (USBH2_HC_MEM_POOL_RELOC == 1)
#define USBH2_HC_MEM_POOL_SECTION(x) USBHn_HC_MEM_POOL_SECTION_(x)
#else
#define USBH2_HC_MEM_POOL_SECTION(x)
#endif
#endif

#ifdef USBH3_HC_NUM
#if (USBH3_HC_MEM_POOL_RELOC == 1)
#define USBH3_HC_MEM_POOL_SECTION(x) USBHn_HC_MEM_POOL_SECTION_(x)
#else
#define USBH3_HC_MEM_POOL_SECTION(x)
#endif
#endif

/*------------------------------------------------------------------------------
* USB Host externals
*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -91,7 +59,7 @@ static const uint32_t usbh0_pipe_num = USBH0_HC_PIPE_NUM;
static const uint32_t usbh0_mem_pool_size = USBH0_HC_MEM_POOL_SIZE;
static const uint8_t usbh0_mem_pool_reloc = USBH0_HC_MEM_POOL_RELOC;
USBH_PIPE usbh0_pipe [USBH0_HC_PIPE_NUM];
static uint32_t usbh0_mem_pool [USBH0_HC_MEM_POOL_SIZE / 4] USBH0_HC_MEM_POOL_SECTION(USBH0_HC_MEM_POOL_SECTION_NAME);
static uint32_t usbh0_mem_pool [USBH0_HC_MEM_POOL_SIZE / 4] USBH0_HC_MEM_POOL_SECTION;
static ARM_DRIVER_USBH *usbh0_hcd_ptr = &USBHn_DRIVER(USBH0_HC_NUM);

// Core Thread definitions
Expand Down Expand Up @@ -133,7 +101,7 @@ static const uint32_t usbh1_pipe_num = USBH1_HC_PIPE_NUM;
static const uint32_t usbh1_mem_pool_size = USBH1_HC_MEM_POOL_SIZE;
static const uint8_t usbh1_mem_pool_reloc = USBH1_HC_MEM_POOL_RELOC;
USBH_PIPE usbh1_pipe [USBH1_HC_PIPE_NUM];
static uint32_t usbh1_mem_pool [USBH1_HC_MEM_POOL_SIZE / 4] USBH1_HC_MEM_POOL_SECTION(USBH1_HC_MEM_POOL_SECTION_NAME);
static uint32_t usbh1_mem_pool [USBH1_HC_MEM_POOL_SIZE / 4] USBH1_HC_MEM_POOL_SECTION;
static ARM_DRIVER_USBH *usbh1_hcd_ptr = &USBHn_DRIVER(USBH1_HC_NUM);

// Core Thread definitions
Expand Down Expand Up @@ -175,7 +143,7 @@ static const uint32_t usbh2_pipe_num = USBH2_HC_PIPE_NUM;
static const uint32_t usbh2_mem_pool_size = USBH2_HC_MEM_POOL_SIZE;
static const uint8_t usbh2_mem_pool_reloc = USBH2_HC_MEM_POOL_RELOC;
USBH_PIPE usbh2_pipe [USBH2_HC_PIPE_NUM];
static uint32_t usbh2_mem_pool [USBH2_HC_MEM_POOL_SIZE / 4] USBH2_HC_MEM_POOL_SECTION(USBH2_HC_MEM_POOL_SECTION_NAME);
static uint32_t usbh2_mem_pool [USBH2_HC_MEM_POOL_SIZE / 4] USBH2_HC_MEM_POOL_SECTION;
static ARM_DRIVER_USBH *usbh2_hcd_ptr = &USBHn_DRIVER(USBH2_HC_NUM);

// Core Thread definitions
Expand Down Expand Up @@ -217,7 +185,7 @@ static const uint32_t usbh3_pipe_num = USBH3_HC_PIPE_NUM;
static const uint32_t usbh3_mem_pool_size = USBH3_HC_MEM_POOL_SIZE;
static const uint8_t usbh3_mem_pool_reloc = USBH3_HC_MEM_POOL_RELOC;
USBH_PIPE usbh3_pipe [USBH3_HC_PIPE_NUM];
static uint32_t usbh3_mem_pool [USBH3_HC_MEM_POOL_SIZE / 4] USBH3_HC_MEM_POOL_SECTION(USBH3_HC_MEM_POOL_SECTION_NAME);
static uint32_t usbh3_mem_pool [USBH3_HC_MEM_POOL_SIZE / 4] USBH3_HC_MEM_POOL_SECTION;
static ARM_DRIVER_USBH *usbh3_hcd_ptr = &USBHn_DRIVER(USBH3_HC_NUM);

// Core Thread definitions
Expand Down
50 changes: 50 additions & 0 deletions Components/USB/Source/usbh_section.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Host
* Copyright (c) 2024 Arm Limited (or its affiliates). All rights reserved.
*------------------------------------------------------------------------------
* Name: usbh_section.h
* Purpose: USB Host (USBH) - Section definitions
*----------------------------------------------------------------------------*/

#ifndef USBH_SECTION_
#define USBH_SECTION_

/*------------------------------------------------------------------------------
* USB Host 0..3 section defines
*----------------------------------------------------------------------------*/

#define USBHn_HC_MEM_POOL_SECTION_(str) __attribute__((section(str)))

#ifdef USBH0_HC_NUM
#if (USBH0_HC_MEM_POOL_RELOC == 1)
#define USBH0_HC_MEM_POOL_SECTION USBHn_HC_MEM_POOL_SECTION_(USBH0_HC_MEM_POOL_SECTION_NAME)
#else
#define USBH0_HC_MEM_POOL_SECTION
#endif
#endif

#ifdef USBH1_HC_NUM
#if (USBH1_HC_MEM_POOL_RELOC == 1)
#define USBH1_HC_MEM_POOL_SECTION USBHn_HC_MEM_POOL_SECTION_(USBH1_HC_MEM_POOL_SECTION_NAME)
#else
#define USBH1_HC_MEM_POOL_SECTION
#endif
#endif

#ifdef USBH2_HC_NUM
#if (USBH2_HC_MEM_POOL_RELOC == 1)
#define USBH2_HC_MEM_POOL_SECTION USBHn_HC_MEM_POOL_SECTION_(USBH2_HC_MEM_POOL_SECTION_NAME)
#else
#define USBH2_HC_MEM_POOL_SECTION
#endif
#endif

#ifdef USBH3_HC_NUM
#if (USBH3_HC_MEM_POOL_RELOC == 1)
#define USBH3_HC_MEM_POOL_SECTION USBHn_HC_MEM_POOL_SECTION_(USBH3_HC_MEM_POOL_SECTION_NAME)
#else
#define USBH3_HC_MEM_POOL_SECTION
#endif
#endif

#endif // USBH_SECTION_

0 comments on commit d3d7611

Please sign in to comment.