Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a21ca5d

Browse files
committed
Allow STM32H driver DMA bufs be placed elsewhere
1 parent e8fc817 commit a21ca5d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

‎mongoose.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24324,11 +24324,11 @@ struct synopsys_enet_qos {
2432424324
#define ETH_DESC_CNT 4 // Descriptors count
2432524325
#define ETH_DS 4 // Descriptor size (words)
2432624326

24327-
#define MG_8BYTE_ALIGNED __attribute__((aligned(8)))
24328-
static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24329-
static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24330-
static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24331-
static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24327+
#define MG_ETH_ATTR __attribute__((aligned(8), section(".eth_ram")))
24328+
static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_ETH_ATTR;
24329+
static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_ETH_ATTR;
24330+
static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_ETH_ATTR;
24331+
static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_ETH_ATTR;
2433224332
static struct mg_tcpip_if *s_ifp; // MIP interface
2433324333

2433424334
static uint16_t eth_read_phy(uint8_t addr, uint8_t reg) {
@@ -24355,12 +24355,14 @@ static bool mg_tcpip_driver_stm32h_init(struct mg_tcpip_if *ifp) {
2435524355
uint8_t phy_conf = d == NULL ? MG_PHY_CLOCKS_MAC : d->phy_conf;
2435624356

2435724357
// Init RX descriptors
24358+
memset((char *) s_rxdesc, 0, sizeof(s_rxdesc)); // manual init
2435824359
for (int i = 0; i < ETH_DESC_CNT; i++) {
2435924360
s_rxdesc[i][0] = (uint32_t) (uintptr_t) s_rxbuf[i]; // Point to data buffer
2436024361
s_rxdesc[i][3] = MG_BIT(31) | MG_BIT(30) | MG_BIT(24); // OWN, IOC, BUF1V
2436124362
}
2436224363

2436324364
// Init TX descriptors
24365+
memset((char *) s_txdesc, 0, sizeof(s_txdesc)); // manual init
2436424366
for (int i = 0; i < ETH_DESC_CNT; i++) {
2436524367
s_txdesc[i][0] = (uint32_t) (uintptr_t) s_txbuf[i]; // Buf pointer
2436624368
}

‎src/drivers/stm32h.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ struct synopsys_enet_qos {
5050
#define ETH_DESC_CNT 4 // Descriptors count
5151
#define ETH_DS 4 // Descriptor size (words)
5252

53-
#define MG_8BYTE_ALIGNED __attribute__((aligned(8)))
54-
static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
55-
static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
56-
static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
57-
static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
53+
#define MG_ETH_ATTR __attribute__((aligned(8), section(".eth_ram")))
54+
static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_ETH_ATTR;
55+
static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_ETH_ATTR;
56+
static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_ETH_ATTR;
57+
static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_ETH_ATTR;
5858
static struct mg_tcpip_if *s_ifp; // MIP interface
5959

6060
static uint16_t eth_read_phy(uint8_t addr, uint8_t reg) {
@@ -81,12 +81,14 @@ static bool mg_tcpip_driver_stm32h_init(struct mg_tcpip_if *ifp) {
8181
uint8_t phy_conf = d == NULL ? MG_PHY_CLOCKS_MAC : d->phy_conf;
8282

8383
// Init RX descriptors
84+
memset((char *) s_rxdesc, 0, sizeof(s_rxdesc)); // manual init
8485
for (int i = 0; i < ETH_DESC_CNT; i++) {
8586
s_rxdesc[i][0] = (uint32_t) (uintptr_t) s_rxbuf[i]; // Point to data buffer
8687
s_rxdesc[i][3] = MG_BIT(31) | MG_BIT(30) | MG_BIT(24); // OWN, IOC, BUF1V
8788
}
8889

8990
// Init TX descriptors
91+
memset((char *) s_txdesc, 0, sizeof(s_txdesc)); // manual init
9092
for (int i = 0; i < ETH_DESC_CNT; i++) {
9193
s_txdesc[i][0] = (uint32_t) (uintptr_t) s_txbuf[i]; // Buf pointer
9294
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /