mirror of
https://github.com/apache/nuttx.git
synced 2025-12-12 13:55:18 +08:00
Compare commits
15 Commits
nuttx-10.3
...
nuttx-10.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3130ff691e | ||
|
|
680225923d | ||
|
|
112d709609 | ||
|
|
70984c5254 | ||
|
|
84438c62f7 | ||
|
|
893989e2f9 | ||
|
|
5a61d80ea3 | ||
|
|
8637a12b31 | ||
|
|
f208a2fee4 | ||
|
|
3784307c46 | ||
|
|
23218318a2 | ||
|
|
f380c919f0 | ||
|
|
367dc9a29a | ||
|
|
a4b1cea3ba | ||
|
|
16748108c5 |
956
ReleaseNotes
956
ReleaseNotes
File diff suppressed because it is too large
Load Diff
@@ -85,7 +85,7 @@ exception_common:
|
||||
|
||||
mv a1, sp /* context = sp */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Switch to interrupt stack */
|
||||
|
||||
lui sp, %hi(g_intstackbase)
|
||||
@@ -150,17 +150,17 @@ exception_common:
|
||||
* Name: g_intstackalloc and g_intstackbase
|
||||
************************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.bss
|
||||
.align 4
|
||||
.balign 16
|
||||
.global g_intstackalloc
|
||||
.global g_intstackbase
|
||||
.type g_intstackalloc, object
|
||||
.type g_intstackbase, object
|
||||
g_intstackalloc:
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3))
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
g_intstackbase:
|
||||
.skip 4
|
||||
.size g_intstackbase, 4
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3)
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#endif
|
||||
|
||||
@@ -78,10 +78,10 @@ void up_irqinitialize(void)
|
||||
|
||||
up_irq_save();
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
|
||||
intstack_size);
|
||||
#endif
|
||||
|
||||
@@ -191,7 +191,7 @@ exception_common:
|
||||
|
||||
mv a1, sp /* context = sp */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Load mhartid (cpuid) */
|
||||
|
||||
csrr s0, mhartid
|
||||
@@ -203,7 +203,7 @@ exception_common:
|
||||
j 4f
|
||||
3:
|
||||
la sp, g_intstackbase
|
||||
addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~7)
|
||||
addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~15)
|
||||
4:
|
||||
|
||||
#endif
|
||||
@@ -264,17 +264,17 @@ exception_common:
|
||||
* Name: g_intstackalloc and g_intstackbase
|
||||
************************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.bss
|
||||
.align 8
|
||||
.balign 16
|
||||
.global g_intstackalloc
|
||||
.global g_intstackbase
|
||||
.type g_intstackalloc, object
|
||||
.type g_intstackbase, object
|
||||
g_intstackalloc:
|
||||
.skip (((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7))
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
g_intstackbase:
|
||||
.skip 8
|
||||
.size g_intstackbase, 8
|
||||
.size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7)
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#endif
|
||||
|
||||
@@ -72,8 +72,8 @@ void up_irqinitialize(void)
|
||||
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7);
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
|
||||
intstack_size);
|
||||
#endif
|
||||
|
||||
@@ -191,17 +191,17 @@ ssize_t up_check_stack_remain(void)
|
||||
return up_check_tcbstack_remain(this_task());
|
||||
}
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
size_t up_check_intstack(void)
|
||||
{
|
||||
return do_stackcheck((uintptr_t)&g_intstackalloc,
|
||||
(CONFIG_ARCH_INTERRUPTSTACK & ~3),
|
||||
(CONFIG_ARCH_INTERRUPTSTACK & ~15),
|
||||
true);
|
||||
}
|
||||
|
||||
size_t up_check_intstack_remain(void)
|
||||
{
|
||||
return (CONFIG_ARCH_INTERRUPTSTACK & ~3) - up_check_intstack();
|
||||
return (CONFIG_ARCH_INTERRUPTSTACK & ~15) - up_check_intstack();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,20 +42,13 @@
|
||||
* Pre-processor Macros
|
||||
****************************************************************************/
|
||||
|
||||
/* RISC-V requires at least a 4-byte stack alignment.
|
||||
* For floating point use, however, the stack must be aligned to 8-byte
|
||||
* addresses.
|
||||
*/
|
||||
/* RISC-V requires a 16-byte stack alignment. */
|
||||
|
||||
#if defined(CONFIG_LIBC_FLOATINGPOINT) || defined (CONFIG_ARCH_RV64GC)
|
||||
# define STACK_ALIGNMENT 8
|
||||
#else
|
||||
# define STACK_ALIGNMENT 4
|
||||
#endif
|
||||
#define STACK_ALIGNMENT 16
|
||||
|
||||
/* Stack alignment macros */
|
||||
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT-1)
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)
|
||||
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
|
||||
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
static inline void up_color_intstack(void)
|
||||
{
|
||||
uint32_t *ptr = (uint32_t *)&g_intstackalloc;
|
||||
ssize_t size;
|
||||
|
||||
for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
size > 0;
|
||||
size -= sizeof(uint32_t))
|
||||
{
|
||||
|
||||
@@ -133,7 +133,7 @@ EXTERN uint32_t g_idle_topstack;
|
||||
|
||||
/* Address of the saved user stack pointer */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
EXTERN uint32_t g_intstackalloc; /* Allocated stack base */
|
||||
EXTERN uint32_t g_intstackbase; /* Initial top of interrupt stack */
|
||||
#endif
|
||||
|
||||
@@ -37,20 +37,13 @@
|
||||
* Pre-processor Macros
|
||||
****************************************************************************/
|
||||
|
||||
/* RISC-V requires at least a 4-byte stack alignment.
|
||||
* For floating point use, however, the stack must be aligned to 8-byte
|
||||
* addresses.
|
||||
*/
|
||||
/* RISC-V requires a 16-byte stack alignment. */
|
||||
|
||||
#if defined(CONFIG_LIBC_FLOATINGPOINT) || defined (CONFIG_ARCH_RV64GC)
|
||||
# define STACK_ALIGNMENT 8
|
||||
#else
|
||||
# define STACK_ALIGNMENT 4
|
||||
#endif
|
||||
#define STACK_ALIGNMENT 16
|
||||
|
||||
/* Stack alignment macros */
|
||||
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT-1)
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)
|
||||
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
|
||||
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
|
||||
|
||||
|
||||
@@ -39,20 +39,13 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* RISC-V requires at least a 4-byte stack alignment.
|
||||
* For floating point use, however, the stack must be aligned to 8-byte
|
||||
* addresses.
|
||||
*/
|
||||
/* RISC-V requires a 16-byte stack alignment. */
|
||||
|
||||
#if defined(CONFIG_LIBC_FLOATINGPOINT) || defined (CONFIG_ARCH_RV64GC)
|
||||
# define STACK_ALIGNMENT 8
|
||||
#else
|
||||
# define STACK_ALIGNMENT 4
|
||||
#endif
|
||||
#define STACK_ALIGNMENT 16
|
||||
|
||||
/* Stack alignment macros */
|
||||
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT-1)
|
||||
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)
|
||||
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
|
||||
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "esp32c3.h"
|
||||
|
||||
#include "hardware/esp32c3_rom_layout.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -64,12 +66,13 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||
*/
|
||||
|
||||
extern uint8_t *_sheap;
|
||||
extern uint8_t *_eheap;
|
||||
extern const struct esp32c3_rom_layout_s *ets_rom_layout_p;
|
||||
|
||||
board_autoled_on(LED_HEAPALLOCATE);
|
||||
|
||||
*heap_start = (FAR void *)&_sheap;
|
||||
*heap_size = (size_t)((uintptr_t)&_eheap - (uintptr_t)&_sheap);
|
||||
*heap_size = (size_t)(ets_rom_layout_p->dram0_rtos_reserved_start -
|
||||
(uintptr_t)&_sheap);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
.section .noinit
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.align 4
|
||||
.balign 16
|
||||
.type g_intstackalloc, @object
|
||||
.type g_intstackbase, @object
|
||||
g_intstackalloc:
|
||||
.skip CONFIG_ARCH_INTERRUPTSTACK
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
g_intstackbase:
|
||||
.size g_intstackalloc, CONFIG_ARCH_INTERRUPTSTACK
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
94
arch/risc-v/src/esp32c3/hardware/esp32c3_rom_layout.h
Normal file
94
arch/risc-v/src/esp32c3/hardware/esp32c3_rom_layout.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/esp32c3/hardware/esp32c3_rom_layout.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_ROM_LAYOUT_H
|
||||
#define __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_ROM_LAYOUT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Structure and functions for returning ROM global layout
|
||||
*
|
||||
* This is for address symbols defined in the linker script,
|
||||
* which may change during ECOs.
|
||||
*/
|
||||
|
||||
struct esp32c3_rom_layout_s
|
||||
{
|
||||
uintptr_t dram0_stack_shared_mem_start;
|
||||
uintptr_t dram0_rtos_reserved_start;
|
||||
uintptr_t stack_sentry;
|
||||
uintptr_t stack;
|
||||
uintptr_t stack_sentry_app;
|
||||
uintptr_t stack_app;
|
||||
|
||||
/* BTDM data */
|
||||
|
||||
uintptr_t data_start_btdm;
|
||||
uintptr_t data_end_btdm;
|
||||
uintptr_t bss_start_btdm;
|
||||
uintptr_t bss_end_btdm;
|
||||
uintptr_t data_start_btdm_rom;
|
||||
uintptr_t data_end_btdm_rom;
|
||||
uintptr_t data_start_interface_btdm;
|
||||
uintptr_t data_end_interface_btdm;
|
||||
uintptr_t bss_start_interface_btdm;
|
||||
uintptr_t bss_end_interface_btdm;
|
||||
|
||||
/* PHY data */
|
||||
|
||||
uintptr_t dram_start_phyrom;
|
||||
uintptr_t dram_end_phyrom;
|
||||
|
||||
/* Wi-Fi data */
|
||||
|
||||
uintptr_t dram_start_coexist;
|
||||
uintptr_t dram_end_coexist;
|
||||
uintptr_t dram_start_net80211;
|
||||
uintptr_t dram_end_net80211;
|
||||
uintptr_t dram_start_pp;
|
||||
uintptr_t dram_end_pp;
|
||||
uintptr_t data_start_interface_coexist;
|
||||
uintptr_t data_end_interface_coexist;
|
||||
uintptr_t bss_start_interface_coexist;
|
||||
uintptr_t bss_end_interface_coexist;
|
||||
uintptr_t data_start_interface_net80211;
|
||||
uintptr_t data_end_interface_net80211;
|
||||
uintptr_t bss_start_interface_net80211;
|
||||
uintptr_t bss_end_interface_net80211;
|
||||
uintptr_t data_start_interface_pp;
|
||||
uintptr_t data_end_interface_pp;
|
||||
uintptr_t bss_start_interface_pp;
|
||||
uintptr_t bss_end_interface_pp;
|
||||
uintptr_t dram_start_usbdev_rom;
|
||||
uintptr_t dram_end_usbdev_rom;
|
||||
uintptr_t dram_start_uart_rom;
|
||||
uintptr_t dram_end_uart_rom;
|
||||
};
|
||||
|
||||
#endif /* __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_ROM_LAYOUT_H */
|
||||
|
||||
@@ -126,7 +126,7 @@ exception_common:
|
||||
|
||||
mv a1, sp /* context = sp */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Switch to interrupt stack */
|
||||
|
||||
lui sp, %hi(g_intstackbase)
|
||||
@@ -188,17 +188,17 @@ exception_common:
|
||||
* Name: g_intstackalloc and g_intstackbase
|
||||
************************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.bss
|
||||
.align 4
|
||||
.balign 16
|
||||
.global g_intstackalloc
|
||||
.global g_intstackbase
|
||||
.type g_intstackalloc, object
|
||||
.type g_intstackbase, object
|
||||
g_intstackalloc:
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3))
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
g_intstackbase:
|
||||
.skip 4
|
||||
.size g_intstackbase, 4
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3)
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#endif
|
||||
|
||||
@@ -59,8 +59,8 @@ void up_irqinitialize(void)
|
||||
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
|
||||
intstack_size);
|
||||
#endif
|
||||
|
||||
@@ -143,7 +143,7 @@ normal_irq:
|
||||
|
||||
mv a1, sp /* context = sp */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Load mhartid (cpuid) */
|
||||
|
||||
csrr s0, mhartid
|
||||
@@ -155,7 +155,7 @@ normal_irq:
|
||||
j 4f
|
||||
3:
|
||||
la sp, g_intstackbase
|
||||
addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~7)
|
||||
addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~15)
|
||||
4:
|
||||
|
||||
#endif
|
||||
@@ -215,17 +215,25 @@ normal_irq:
|
||||
* Name: g_intstackalloc and g_intstackbase
|
||||
************************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.bss
|
||||
.align 8
|
||||
.balign 16
|
||||
.global g_intstackalloc
|
||||
.global g_intstackbase
|
||||
.type g_intstackalloc, object
|
||||
.type g_intstackbase, object
|
||||
g_intstackalloc:
|
||||
.skip (((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7))
|
||||
#ifndef CONFIG_SMP
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
#else
|
||||
.skip (((CONFIG_ARCH_INTERRUPTSTACK * CONFIG_SMP_NCPUS) + 8) & ~15)
|
||||
#endif
|
||||
g_intstackbase:
|
||||
.skip 8
|
||||
.size g_intstackbase, 8
|
||||
.size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7)
|
||||
#ifndef CONFIG_SMP
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#else
|
||||
.size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * CONFIG_SMP_NCPUS) & ~15)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -80,8 +80,13 @@ void up_irqinitialize(void)
|
||||
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7);
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
size_t intstack_size = 0;
|
||||
#ifndef CONFIG_SMP
|
||||
intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
#else
|
||||
intstack_size = ((CONFIG_ARCH_INTERRUPTSTACK * CONFIG_SMP_NCPUS) & ~15);
|
||||
#endif
|
||||
riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
|
||||
intstack_size);
|
||||
#endif
|
||||
|
||||
@@ -126,7 +126,7 @@ exception_common:
|
||||
|
||||
mv a1, sp /* context = sp */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
/* Switch to interrupt stack */
|
||||
|
||||
lui sp, %hi(g_intstackbase)
|
||||
@@ -188,17 +188,17 @@ exception_common:
|
||||
* Name: g_intstackalloc and g_intstackbase
|
||||
************************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
.bss
|
||||
.align 4
|
||||
.balign 16
|
||||
.global g_intstackalloc
|
||||
.global g_intstackbase
|
||||
.type g_intstackalloc, object
|
||||
.type g_intstackbase, object
|
||||
g_intstackalloc:
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3))
|
||||
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15)
|
||||
g_intstackbase:
|
||||
.skip 4
|
||||
.size g_intstackbase, 4
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3)
|
||||
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
|
||||
#endif
|
||||
|
||||
@@ -58,8 +58,8 @@ void up_irqinitialize(void)
|
||||
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
|
||||
riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
|
||||
intstack_size);
|
||||
#endif
|
||||
|
||||
@@ -173,7 +173,7 @@ static void riscv_dumpstate(void)
|
||||
uint32_t sp = riscv_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
uint32_t istackbase;
|
||||
uint32_t istacksize;
|
||||
#endif
|
||||
@@ -189,9 +189,9 @@ static void riscv_dumpstate(void)
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
istackbase = (uint32_t)&g_intstackbase;
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4;
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~15) - 4;
|
||||
|
||||
/* Show interrupt stack info */
|
||||
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STACK_ALIGNMENT
|
||||
# define CONFIG_STACK_ALIGNMENT 4
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -184,7 +184,7 @@ static void up_dumpstate(void)
|
||||
uint64_t sp = riscv_getsp();
|
||||
uintptr_t ustackbase;
|
||||
uintptr_t ustacksize;
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
uintptr_t istackbase;
|
||||
uintptr_t istacksize;
|
||||
#endif
|
||||
@@ -200,9 +200,9 @@ static void up_dumpstate(void)
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||
istackbase = (uintptr_t)&g_intstackbase;
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~7) - 8;
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~15) - 8;
|
||||
|
||||
/* Show interrupt stack info */
|
||||
|
||||
|
||||
@@ -1802,8 +1802,10 @@ static int32_t esp_task_create_pinned_to_core(void *entry,
|
||||
(char * const *)param);
|
||||
if (pid > 0)
|
||||
{
|
||||
*((int *)task_handle) = pid;
|
||||
|
||||
if (task_handle != NULL)
|
||||
{
|
||||
*((int *)task_handle) = pid;
|
||||
}
|
||||
#ifdef CONFIG_SMP
|
||||
if (core_id < CONFIG_SMP_NCPUS)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,20 @@
|
||||
#define SPI_TX_MAXSIZE (CONFIG_CXD56_DMAC_SPI5_TX_MAXSIZE)
|
||||
#define SPI_RX_MAXSIZE (CONFIG_CXD56_DMAC_SPI5_RX_MAXSIZE)
|
||||
|
||||
#if defined(CONFIG_WIFI_BOARD_IS110B_HARDWARE_VERSION_10B)
|
||||
/* v1.0b */
|
||||
#define GS2200M_GPIO_37 (PIN_UART2_CTS)
|
||||
#define GS2200M_EXT_RTC_RESET_IN (PIN_EMMC_DATA3)
|
||||
#elif defined(CONFIG_WIFI_BOARD_IS110B_HARDWARE_VERSION_10C)
|
||||
/* v1.0c */
|
||||
#define GS2200M_GPIO_37 (PIN_EMMC_DATA2)
|
||||
#define GS2200M_EXT_RTC_RESET_IN (PIN_EMMC_DATA3)
|
||||
#else
|
||||
/* v1.0a */
|
||||
#define GS2200M_GPIO_37 (PIN_UART2_CTS)
|
||||
#define GS2200M_EXT_RTC_RESET_IN (PIN_UART2_RTS)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -84,7 +98,7 @@ static volatile uint32_t _n_called;
|
||||
|
||||
static int gs2200m_irq_attach(xcpt_t handler, FAR void *arg)
|
||||
{
|
||||
cxd56_gpioint_config(PIN_UART2_CTS,
|
||||
cxd56_gpioint_config(GS2200M_GPIO_37,
|
||||
GPIOINT_LEVEL_HIGH,
|
||||
handler,
|
||||
arg);
|
||||
@@ -104,7 +118,7 @@ static void gs2200m_irq_enable(void)
|
||||
|
||||
if (0 == _enable_count)
|
||||
{
|
||||
cxd56_gpioint_enable(PIN_UART2_CTS);
|
||||
cxd56_gpioint_enable(GS2200M_GPIO_37);
|
||||
}
|
||||
|
||||
_enable_count++;
|
||||
@@ -127,7 +141,7 @@ static void gs2200m_irq_disable(void)
|
||||
|
||||
if (0 == _enable_count)
|
||||
{
|
||||
cxd56_gpioint_disable(PIN_UART2_CTS);
|
||||
cxd56_gpioint_disable(GS2200M_GPIO_37);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
@@ -141,7 +155,7 @@ static uint32_t gs2200m_dready(int *ec)
|
||||
{
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
uint32_t r = cxd56_gpio_read(PIN_UART2_CTS);
|
||||
uint32_t r = cxd56_gpio_read(GS2200M_GPIO_37);
|
||||
|
||||
if (ec)
|
||||
{
|
||||
@@ -160,7 +174,7 @@ static uint32_t gs2200m_dready(int *ec)
|
||||
|
||||
static void gs2200m_reset(bool reset)
|
||||
{
|
||||
cxd56_gpio_write(PIN_UART2_RTS, !reset);
|
||||
cxd56_gpio_write(GS2200M_EXT_RTC_RESET_IN, !reset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -222,8 +236,8 @@ int board_gs2200m_initialize(FAR const char *devpath, int bus)
|
||||
/* Change UART2 to GPIO */
|
||||
|
||||
CXD56_PIN_CONFIGS(PINCONFS_UART2_GPIO);
|
||||
cxd56_gpio_config(PIN_UART2_CTS, true);
|
||||
cxd56_gpio_config(PIN_UART2_RTS, false);
|
||||
cxd56_gpio_config(GS2200M_GPIO_37, true);
|
||||
cxd56_gpio_config(GS2200M_EXT_RTC_RESET_IN, false);
|
||||
|
||||
/* Initialize spi device */
|
||||
|
||||
|
||||
@@ -515,6 +515,23 @@ config LCD_ON_MAIN_BOARD
|
||||
|
||||
endchoice
|
||||
endif
|
||||
|
||||
choice
|
||||
prompt "Spresense Wi-Fi Add-on board (iS110B)"
|
||||
default WIFI_BOARD_IS110B_HARDWARE_VERSION_10A
|
||||
---help---
|
||||
Specify the hardware version of Wi-Fi Add-on board (iS110B)
|
||||
|
||||
config WIFI_BOARD_IS110B_HARDWARE_VERSION_10A
|
||||
bool "WIFI Board iS110B v1.0A"
|
||||
|
||||
config WIFI_BOARD_IS110B_HARDWARE_VERSION_10B
|
||||
bool "WIFI Board iS110B v1.0B"
|
||||
|
||||
config WIFI_BOARD_IS110B_HARDWARE_VERSION_10C
|
||||
bool "WIFI Board iS110B v1.0C"
|
||||
endchoice
|
||||
|
||||
comment "LTE Options"
|
||||
|
||||
menuconfig CXD56_LTE
|
||||
|
||||
@@ -82,10 +82,6 @@ MEMORY
|
||||
|
||||
}
|
||||
|
||||
/* Heap ends at the start of the static data of the ROM bootloader */
|
||||
|
||||
_eheap = 0x3fccae00;
|
||||
|
||||
#if CONFIG_ESP32C3_DEVKIT_RUN_IRAM
|
||||
REGION_ALIAS("default_rodata_seg", dram0_0_seg);
|
||||
REGION_ALIAS("default_code_seg", iram0_0_seg);
|
||||
|
||||
@@ -650,7 +650,7 @@ static bool _copy_data_from_pkt(FAR struct gs2200m_dev_s *dev,
|
||||
|
||||
pkt_dat->remain -= len;
|
||||
|
||||
if (0 == pkt_dat->remain)
|
||||
if (0 == pkt_dat->remain || TYPE_BULK_DATA_UDP == pkt_dat->type)
|
||||
{
|
||||
_remove_and_free_pkt(dev, c);
|
||||
}
|
||||
@@ -1568,6 +1568,27 @@ errout:
|
||||
return r;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gs2200m_send_cmd2
|
||||
****************************************************************************/
|
||||
|
||||
static enum pkt_type_e gs2200m_send_cmd2(FAR struct gs2200m_dev_s *dev,
|
||||
FAR char *cmd)
|
||||
{
|
||||
struct pkt_dat_s pkt_dat;
|
||||
enum pkt_type_e r;
|
||||
|
||||
/* Initialize pkt_dat and send */
|
||||
|
||||
memset(&pkt_dat, 0, sizeof(pkt_dat));
|
||||
r = gs2200m_send_cmd(dev, cmd, &pkt_dat);
|
||||
|
||||
/* Release the pkt_dat */
|
||||
|
||||
_release_pkt_dat(dev, &pkt_dat);
|
||||
return r;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gs2200m_set_opmode
|
||||
* NOTE: See 5.1.2 Operation Mode
|
||||
@@ -1580,7 +1601,7 @@ static enum pkt_type_e gs2200m_set_opmode(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[20];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WM=%d\r\n", mode);
|
||||
t = gs2200m_send_cmd(dev, cmd, NULL);
|
||||
t = gs2200m_send_cmd2(dev, cmd);
|
||||
|
||||
if (TYPE_OK == t)
|
||||
{
|
||||
@@ -1636,7 +1657,7 @@ errout:
|
||||
|
||||
static enum pkt_type_e gs2200m_disassociate(FAR struct gs2200m_dev_s *dev)
|
||||
{
|
||||
return gs2200m_send_cmd(dev, (char *)"AT+WD\r\n", NULL);
|
||||
return gs2200m_send_cmd2(dev, (char *)"AT+WD\r\n");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1650,7 +1671,7 @@ static enum pkt_type_e gs2200m_enable_dhcpc(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[16];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+NDHCP=%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1664,7 +1685,7 @@ static enum pkt_type_e gs2200m_calc_key(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[80];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WPAPSK=%s,%s\r\n", ssid, psk);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1678,7 +1699,7 @@ static enum pkt_type_e gs2200m_set_security(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[16];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WSEC=%d\r\n", mode);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1749,7 +1770,8 @@ static enum pkt_type_e gs2200m_set_addresses(FAR struct gs2200m_dev_s *dev,
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+NSET=%s,%s,%s\r\n",
|
||||
address, netmask, gateway);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1763,7 +1785,7 @@ static enum pkt_type_e gs2200m_enable_dhcps(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[20];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+DHCPSRVR=%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1777,7 +1799,7 @@ static enum pkt_type_e gs2200m_set_auth(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[16];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WAUTH=%d\r\n", mode);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WL_GS2200M_ENABLE_WEP
|
||||
@@ -1793,7 +1815,7 @@ static enum pkt_type_e gs2200m_set_wepkey(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[32];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WWEP1=%s\r\n", key);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -1809,7 +1831,7 @@ static enum pkt_type_e gs2200m_set_wpa2pf(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[64];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WWPA=%s\r\n", key);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_WL_GS2200M_ENABLE_WEP */
|
||||
@@ -2038,21 +2060,10 @@ static enum pkt_type_e gs2200m_send_bulk(FAR struct gs2200m_dev_s *dev,
|
||||
static enum pkt_type_e gs2200m_close_conn(FAR struct gs2200m_dev_s *dev,
|
||||
char cid)
|
||||
{
|
||||
struct pkt_dat_s pkt_dat;
|
||||
enum pkt_type_e r;
|
||||
char cmd[15];
|
||||
|
||||
/* Prepare cmd */
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+NCLOSE=%c\r\n", cid);
|
||||
|
||||
/* Initialize pkt_dat and send */
|
||||
|
||||
memset(&pkt_dat, 0, sizeof(pkt_dat));
|
||||
r = gs2200m_send_cmd(dev, cmd, &pkt_dat);
|
||||
|
||||
_release_pkt_dat(dev, &pkt_dat);
|
||||
return r;
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2066,7 +2077,7 @@ static enum pkt_type_e gs2200m_enable_bulk(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[20];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+BDATA=%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2080,7 +2091,7 @@ static enum pkt_type_e gs2200m_enable_echo(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[8];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "ATE%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2094,7 +2105,7 @@ static enum pkt_type_e gs2200m_activate_wrx(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[30];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+WRXACTIVE=%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2109,7 +2120,7 @@ static enum pkt_type_e gs2200m_set_gpio(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[24];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+DGPIO=%d,%d\r\n", n, val);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2125,7 +2136,7 @@ static enum pkt_type_e gs2200m_set_loglevel(FAR struct gs2200m_dev_s *dev,
|
||||
char cmd[16];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+LOGLVL=%d\r\n", level);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2139,7 +2150,7 @@ static enum pkt_type_e gs2200m_get_version(FAR struct gs2200m_dev_s *dev)
|
||||
char cmd[16];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+VER=??\r\n");
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
return gs2200m_send_cmd2(dev, cmd);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ int fs_getfilep(int fd, FAR struct file **filep)
|
||||
_files_semgive(list);
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define IFF_UP (1 << 1) /* Interface is up */
|
||||
#define IFF_RUNNING (1 << 2) /* Carrier is available */
|
||||
#define IFF_IPv6 (1 << 3) /* Configured for IPv6 packet (vs ARP or IPv4) */
|
||||
#define IFF_BOUND (1 << 4) /* Bound to a socket */
|
||||
#define IFF_NOARP (1 << 7) /* ARP is not required for this packet */
|
||||
|
||||
/* Interface flag helpers */
|
||||
@@ -51,20 +52,23 @@
|
||||
#define IFF_SET_DOWN(f) do { (f) |= IFF_DOWN; } while (0)
|
||||
#define IFF_SET_UP(f) do { (f) |= IFF_UP; } while (0)
|
||||
#define IFF_SET_RUNNING(f) do { (f) |= IFF_RUNNING; } while (0)
|
||||
#define IFF_SET_BOUND(f) do { (f) |= IFF_BOUND; } while (0)
|
||||
#define IFF_SET_NOARP(f) do { (f) |= IFF_NOARP; } while (0)
|
||||
|
||||
#define IFF_CLR_DOWN(f) do { (f) &= ~IFF_DOWN; } while (0)
|
||||
#define IFF_CLR_UP(f) do { (f) &= ~IFF_UP; } while (0)
|
||||
#define IFF_CLR_RUNNING(f) do { (f) &= ~IFF_RUNNING; } while (0)
|
||||
#define IFF_CLR_BOUND(f) do { (f) &= ~IFF_BOUND; } while (0)
|
||||
#define IFF_CLR_NOARP(f) do { (f) &= ~IFF_NOARP; } while (0)
|
||||
|
||||
#define IFF_IS_DOWN(f) (((f) & IFF_DOWN) != 0)
|
||||
#define IFF_IS_UP(f) (((f) & IFF_UP) != 0)
|
||||
#define IFF_IS_RUNNING(f) (((f) & IFF_RUNNING) != 0)
|
||||
#define IFF_IS_BOUND(f) (((f) & IFF_BOUND) != 0)
|
||||
#define IFF_IS_NOARP(f) (((f) & IFF_NOARP) != 0)
|
||||
|
||||
/* We only need to manage the IPv6 bit if both IPv6 and IPv4 are supported.
|
||||
* Otherwise, we can save a few bytes by ignoring it.
|
||||
* Otherwise, we can save a few bytes by ignoring it.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||
|
||||
@@ -1354,39 +1354,6 @@ void up_irqinitialize(void);
|
||||
|
||||
bool up_interrupt_context(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Save the current interrupt state and disable interrupts.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Interrupt state prior to disabling interrupts.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore the previous irq state (i.e., the one previously
|
||||
* returned by up_irq_save())
|
||||
*
|
||||
* Input Parameters:
|
||||
* irqstate - The interrupt state to be restored.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t irqstate);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_enable_irq
|
||||
*
|
||||
|
||||
@@ -297,7 +297,14 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (ipv4->proto != IP_PROTO_UDP)
|
||||
#if defined(NET_UDP_HAVE_STACK) && defined(CONFIG_NET_UDP_BINDTODEVICE)
|
||||
/* If the UDP protocol specific socket option UDP_BINDTODEVICE
|
||||
* is selected, then we must forward all UDP packets to the bound
|
||||
* socket.
|
||||
*/
|
||||
|
||||
if (ipv4->proto != IP_PROTO_UDP || !IFF_IS_BOUND(dev->d_flags))
|
||||
#endif
|
||||
{
|
||||
/* Not destined for us and not forwardable... Drop the
|
||||
* packet.
|
||||
|
||||
@@ -433,7 +433,14 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (nxthdr != IP_PROTO_UDP)
|
||||
#if defined(NET_UDP_HAVE_STACK) && defined(CONFIG_NET_UDP_BINDTODEVICE)
|
||||
/* If the UDP protocol specific socket option UDP_BINDTODEVICE
|
||||
* is selected, then we must forward all UDP packets to the bound
|
||||
* socket.
|
||||
*/
|
||||
|
||||
if (nxthdr != IP_PROTO_UDP || !IFF_IS_BOUND(dev->d_flags))
|
||||
#endif
|
||||
{
|
||||
/* Not destined for us and not forwardable...
|
||||
* drop the packet.
|
||||
|
||||
@@ -156,8 +156,7 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
#ifdef CONFIG_NET_LOCAL_DGRAM
|
||||
FAR struct local_conn_s *conn = (FAR struct local_conn_s *)psock->s_conn;
|
||||
FAR struct sockaddr_un *unaddr = (FAR struct sockaddr_un *)to;
|
||||
ssize_t nsent;
|
||||
int ret;
|
||||
ssize_t ret;
|
||||
|
||||
/* Verify that a valid address has been provided */
|
||||
|
||||
@@ -212,7 +211,7 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
ret = local_create_halfduplex(conn, unaddr->sun_path);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to create FIFO for %s: %d\n",
|
||||
nerr("ERROR: Failed to create FIFO for %s: %zd\n",
|
||||
conn->lc_path, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -224,25 +223,18 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
(flags & MSG_DONTWAIT) != 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to open FIFO for %s: %d\n",
|
||||
nerr("ERROR: Failed to open FIFO for %s: %zd\n",
|
||||
unaddr->sun_path, ret);
|
||||
|
||||
nsent = ret;
|
||||
goto errout_with_halfduplex;
|
||||
}
|
||||
|
||||
/* Send the packet */
|
||||
|
||||
nsent = local_send_packet(&conn->lc_outfile, buf, len);
|
||||
if (nsent < 0)
|
||||
ret = local_send_packet(&conn->lc_outfile, buf, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to send the packet: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* local_send_packet returns 0 if all 'len' bytes were sent */
|
||||
|
||||
nsent = len;
|
||||
nerr("ERROR: Failed to send the packet: %zd\n", ret);
|
||||
}
|
||||
|
||||
/* Now we can close the write-only socket descriptor */
|
||||
@@ -255,7 +247,8 @@ errout_with_halfduplex:
|
||||
/* Release our reference to the half duplex FIFO */
|
||||
|
||||
local_release_halfduplex(conn);
|
||||
return nsent;
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return -EISCONN;
|
||||
#endif /* CONFIG_NET_LOCAL_DGRAM */
|
||||
|
||||
@@ -29,10 +29,14 @@
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
#include "netdev/netdev.h"
|
||||
#include "udp/udp.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
@@ -63,7 +67,7 @@ int udp_close(FAR struct socket *psock)
|
||||
unsigned int timeout = UINT_MAX;
|
||||
int ret;
|
||||
|
||||
/* Interrupts are disabled here to avoid race conditions */
|
||||
/* Lock the network to avoid race conditions */
|
||||
|
||||
net_lock();
|
||||
|
||||
@@ -102,6 +106,28 @@ int udp_close(FAR struct socket *psock)
|
||||
nerr("ERROR: udp_txdrain() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_UDP_BINDTODEVICE
|
||||
/* Is the socket bound to an interface device */
|
||||
|
||||
if (conn->boundto != 0)
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Yes, get the interface that we are bound do. NULL would indicate
|
||||
* that the interface no longer exists for some reason.
|
||||
*/
|
||||
|
||||
dev = netdev_findbyindex(conn->boundto);
|
||||
if (dev != NULL)
|
||||
{
|
||||
/* Clear the interface flag to unbind the device from the socket.
|
||||
*/
|
||||
|
||||
IFF_CLR_BOUND(dev->d_flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_UDP_WRITE_BUFFERS
|
||||
/* Free any semi-permanent write buffer callback in place. */
|
||||
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
|
||||
#include "socket/socket.h"
|
||||
@@ -112,31 +114,74 @@ int udp_setsockopt(FAR struct socket *psock, int option,
|
||||
*/
|
||||
|
||||
case UDP_BINDTODEVICE: /* Bind socket to a specific network device */
|
||||
if (value == NULL || value_len == 0 ||
|
||||
(value_len > 0 && ((FAR char *)value)[0] == 0))
|
||||
{
|
||||
conn->boundto = 0; /* This interface is no longer bound */
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ifindex;
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Get the interface index corresponding to the interface name */
|
||||
/* Check if we are are unbinding the socket */
|
||||
|
||||
ifindex = netdev_nametoindex(value);
|
||||
if (ifindex >= 0)
|
||||
{
|
||||
DEBUGASSERT(ifindex > 0 && ifindex <= MAX_IFINDEX);
|
||||
conn->boundto = ifindex;
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ifindex;
|
||||
}
|
||||
}
|
||||
if (value == NULL || value_len == 0 ||
|
||||
(value_len > 0 && ((FAR char *)value)[0] == 0))
|
||||
{
|
||||
/* Just report success if the socket is not bound to an
|
||||
* interface.
|
||||
*/
|
||||
|
||||
if (conn->boundto != 0)
|
||||
{
|
||||
/* Get the interface that we are bound do. NULL would
|
||||
* indicate that the interface no longer exists for some
|
||||
* reason.
|
||||
*/
|
||||
|
||||
dev = netdev_findbyindex(conn->boundto);
|
||||
if (dev != NULL)
|
||||
{
|
||||
/* Clear the interface flag to unbind the device from
|
||||
* the socket.
|
||||
*/
|
||||
|
||||
IFF_CLR_BOUND(dev->d_flags);
|
||||
}
|
||||
|
||||
conn->boundto = 0; /* This interface is no longer bound */
|
||||
}
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* No, we are binding a socket to the interface. */
|
||||
|
||||
else
|
||||
{
|
||||
/* Find the interface device with this name */
|
||||
|
||||
dev = netdev_findbyname(value);
|
||||
if (dev == NULL)
|
||||
{
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
/* An interface may be bound only to one socket. */
|
||||
|
||||
else if (IFF_IS_BOUND(dev->d_flags))
|
||||
{
|
||||
ret = -EBUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the interface to a socket */
|
||||
|
||||
IFF_SET_BOUND(dev->d_flags);
|
||||
|
||||
/* Bind the socket to the interface */
|
||||
|
||||
DEBUGASSERT(dev->d_ifindex > 0 &&
|
||||
dev->d_ifindex <= MAX_IFINDEX);
|
||||
conn->boundto = dev->d_ifindex;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user