• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision13889 (tree)
Time2020-10-15 17:37:02
Authorgdisirio

Log Message

Various patches related to MACv2 and LWIP.

Change Summary

Incremental Difference

--- trunk/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c (revision 13888)
+++ trunk/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c (revision 13889)
@@ -30,6 +30,39 @@
3030
3131 #include "hal_mii.h"
3232
33+/* Fixes for errors in ST headers.*/
34+#if ETH_DMADSR_RPS_FETCHING_Pos == 12
35+#undef ETH_DMADSR_RPS_FETCHING_Pos
36+#define ETH_DMADSR_RPS_FETCHING_Pos (8U)
37+#endif
38+
39+#if ETH_DMADSR_RPS_WAITING_Pos == 12
40+#undef ETH_DMADSR_RPS_WAITING_Pos
41+#define ETH_DMADSR_RPS_WAITING_Pos (9U)
42+#endif
43+
44+#if ETH_DMADSR_RPS_SUSPENDED_Pos == 14
45+#undef ETH_DMADSR_RPS_SUSPENDED_Pos
46+#define ETH_DMADSR_RPS_SUSPENDED_Pos (10U)
47+#endif
48+
49+#if ETH_DMADSR_RPS_CLOSING_Pos == 12
50+#undef ETH_DMADSR_RPS_CLOSING_Pos
51+#define ETH_DMADSR_RPS_CLOSING_Pos (10U)
52+#endif
53+
54+#if ETH_DMADSR_RPS_TIMESTAMP_WR_Pos == 13
55+#undef ETH_DMADSR_RPS_TIMESTAMP_WR_Pos
56+#undef ETH_DMADSR_RPS_TIMESTAMP_WR_Msk
57+#define ETH_DMADSR_RPS_TIMESTAMP_WR_Pos (10U)
58+#define ETH_DMADSR_RPS_TIMESTAMP_WR_Msk (0x6UL << ETH_DMADSR_RPS_TIMESTAMP_WR_Pos)
59+#endif
60+
61+#if ETH_DMADSR_RPS_TRANSFERRING_Pos == 12
62+#undef ETH_DMADSR_RPS_TRANSFERRING_Pos
63+#define ETH_DMADSR_RPS_TRANSFERRING_Pos (10U)
64+#endif
65+
3366 /*===========================================================================*/
3467 /* Driver local definitions. */
3568 /*===========================================================================*/
@@ -519,7 +552,7 @@
519552 __DSB();
520553
521554 /* If the DMA engine is stalled then a restart request is issued.*/
522- if ((ETH->DMACSR & ETH_DMACSR_TPS) == ETH_DMADSR_TPS_SUSPENDED) {
555+ if ((ETH->DMADSR & ETH_DMADSR_TPS) == ETH_DMADSR_TPS_SUSPENDED) {
523556 ETH->DMACSR = ETH_DMACSR_TBU;
524557 }
525558 ETH->DMACTDTPR = 0;
@@ -596,7 +629,7 @@
596629 __DSB();
597630
598631 /* If the DMA engine is stalled then a restart request is issued.*/
599- if ((ETH->DMACSR & ETH_DMACSR_RPS) == ETH_DMADSR_RPS_SUSPENDED) {
632+ if ((ETH->DMADSR & ETH_DMADSR_RPS) == ETH_DMADSR_RPS_SUSPENDED) {
600633 ETH->DMACSR = ETH_DMACSR_RBU;
601634 }
602635 ETH->DMACRDTPR = 0;
--- trunk/os/various/lwip_bindings/arch/sys_arch.c (revision 13888)
+++ trunk/os/various/lwip_bindings/arch/sys_arch.c (revision 13889)
@@ -61,7 +61,18 @@
6161
6262 #include "arch/cc.h"
6363 #include "arch/sys_arch.h"
64+#include "lwipopts.h"
6465
66+#ifndef CH_LWIP_USE_MEM_POOLS
67+#define CH_LWIP_USE_MEM_POOLS FALSE
68+#endif
69+
70+#if CH_LWIP_USE_MEM_POOLS
71+static MEMORYPOOL_DECL(lwip_sys_arch_sem_pool, sizeof(semaphore_t), 4, chCoreAllocAlignedI);
72+static MEMORYPOOL_DECL(lwip_sys_arch_mbox_pool, sizeof(mailbox_t) + sizeof(msg_t) * TCPIP_MBOX_SIZE, 4, chCoreAllocAlignedI);
73+static MEMORYPOOL_DECL(lwip_sys_arch_thread_pool, THD_WORKING_AREA_SIZE(TCPIP_THREAD_STACKSIZE), PORT_WORKING_AREA_ALIGN, chCoreAllocAlignedI);
74+#endif
75+
6576 void sys_init(void) {
6677
6778 }
@@ -68,7 +79,12 @@
6879
6980 err_t sys_sem_new(sys_sem_t *sem, u8_t count) {
7081
82+#if !CH_LWIP_USE_MEM_POOLS
7183 *sem = chHeapAlloc(NULL, sizeof(semaphore_t));
84+#else
85+ *sem = chPoolAlloc(&lwip_sys_arch_sem_pool);
86+#endif
87+
7288 if (*sem == 0) {
7389 SYS_STATS_INC(sem.err);
7490 return ERR_MEM;
@@ -82,7 +98,11 @@
8298
8399 void sys_sem_free(sys_sem_t *sem) {
84100
101+#if !CH_LWIP_USE_MEM_POOLS
85102 chHeapFree(*sem);
103+#else
104+ chPoolFree(&lwip_sys_arch_sem_pool, *sem);
105+#endif
86106 *sem = SYS_SEM_NULL;
87107 SYS_STATS_DEC(sem.used);
88108 }
@@ -128,7 +148,11 @@
128148
129149 err_t sys_mbox_new(sys_mbox_t *mbox, int size) {
130150
151+#if !CH_LWIP_USE_MEM_POOLS
131152 *mbox = chHeapAlloc(NULL, sizeof(mailbox_t) + sizeof(msg_t) * size);
153+#else
154+ *mbox = chPoolAlloc(&lwip_sys_arch_mbox_pool);
155+#endif
132156 if (*mbox == 0) {
133157 SYS_STATS_INC(mbox.err);
134158 return ERR_MEM;
@@ -154,7 +178,11 @@
154178 SYS_STATS_INC(mbox.err);
155179 chMBReset(*mbox);
156180 }
181+#if !CH_LWIP_USE_MEM_POOLS
157182 chHeapFree(*mbox);
183+#else
184+ chPoolFree(&lwip_sys_arch_mbox_pool, *mbox);
185+#endif
158186 *mbox = SYS_MBOX_NULL;
159187 SYS_STATS_DEC(mbox.used);
160188 }
@@ -210,8 +238,14 @@
210238 void *arg, int stacksize, int prio) {
211239 thread_t *tp;
212240
241+#if !CH_LWIP_USE_MEM_POOLS
213242 tp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(stacksize),
214243 name, prio, (tfunc_t)thread, arg);
244+#else
245+ (void) stacksize;
246+ tp = chThdCreateFromMemoryPool(&lwip_sys_arch_thread_pool, name,
247+ prio, (tfunc_t)thread, arg);
248+#endif
215249 return (sys_thread_t)tp;
216250 }
217251
--- trunk/readme.txt (revision 13888)
+++ trunk/readme.txt (revision 13889)
@@ -74,6 +74,8 @@
7474 *****************************************************************************
7575
7676 *** Next ***
77+- NEW: Added option to LWIP bindings to use memory pools instead of heap
78+ allocator.
7779 - NEW: Added MACv2 driver for STM32H7xx.
7880 - NEW: Added support for UART9 and UART10 in STM32 USARTv1 drivers.
7981 - NEW: Added board support for ST_STM32G474RE_DISCOVERY_DPOW1, added demo.
Show on old repository browser