FreeRTOS / FreeRTOS-Kernel

FreeRTOS kernel files only, submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
https://www.FreeRTOS.org
MIT License
2.51k stars 1.05k forks source link

[Feature Request] The number of system calls needs to support the sizeof(uintptr_t) #1015

Closed snikeguo closed 3 months ago

snikeguo commented 3 months ago

Is your feature request related to a problem? Please describe. I need to add a custom SystemCall instruction to execute a custom function. However, the maximum number of system call instructions is 255.

Describe the solution you'd like

....
#define SYSTEM_CALL_User   80
#define SYSTEM_CALL_xUartSend   10001 
....
PRIVILEGED_DATA UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ] =
{
 ...
 xUartSendImpl,
}

...
BaseType_t MPU_xUartSend(..... )
{
__asm volatile
(
    " .syntax unified                                       \n"
                " .extern MPU_xUartSendImpl                            \n"
                "                                                       \n"
                " push {r0}                                             \n"
                " mrs r0, control                                       \n"
                " tst r0, #1                                            \n"
                " pop {r0}                                              \n"
                " bne MPU_xUartSend_Unpriv                             \n"
                " MPU_xUartSend_Priv:                                  \n"
                "     b MPU_xUartSendImpl                              \n"
                " MPU_xUartSend_Unpriv                                 \n"
                "     svc %0                                            \n"
                "                                                       \n"
               pc+x : "i" ( SYSTEM_CALL_User ) : "memory" 
                pc+y : "i" ( .word SYSTEM_CALL_xUartSend   ) : "memory"  //define a word :system call id I am not familiar with assembly syntax.
);
} 
...
void vSystemCallEnter( uint32_t * pulTaskStack,
                           uint32_t ulLR,
                           uint8_t ucSystemCallNumber ) 
{
....
ulSystemCallLocation = pulTaskStack[ portOFFSET_TO_PC ];
if( ( ulSystemCallLocation >= ( uint32_t ) __syscalls_flash_start__ ) &&
            ( ulSystemCallLocation <= ( uint32_t ) __syscalls_flash_end__ ) &&
            ( pxMpuSettings->xSystemCallStackInfo.pulTaskStack == NULL ) &&
            ( uxSystemCallImplementations[ ucSystemCallNumber ] != ( UBaseType_t ) 0 ) )
{
...
 uint32_t systemCallId=*(pulTaskStack[ portOFFSET_TO_PC ]+x);//get user system call id
if( systemCallId>=SYSTEM_CALL_User )
{
    systemCallId=*(pulTaskStack[ portOFFSET_TO_PC ]+y); 
}
.....
 ......
...
}
....
}

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

How many devices will this feature impact? Expected volume for your product.

What are your project timelines? Timeline for milestones such as design completion, testing and validation, and production.

Additional context Add any other context or screenshots about the feature request here.

If you have the same (or similar) feature request, please upvote this issue with thumbs up 👍 and use the comments section to provide answers to the questions above.

Skptak commented 3 months ago

What port are you using? The ARMv7-M and ARMv8-M architectures only support an 8 bit SVC value. Link to the ARMv7M Architecture doc Link to the ARMv8M Architecture Download page, the relevant section is C2.4.242 SVC

image

As this is a Hardware Limitation this request isn't a feature that FreeRTOS can support

snikeguo commented 3 months ago

@Skptak I have made changes to the implementation. Please refresh the page to view my ideas.

Skptak commented 3 months ago

Your proposed change is a larger design change, and more of a feature request. Can you open a post on the FreeRTOS Forums to discuss it there please?

aggarg commented 3 months ago

As @Skptak suggested, please open a forum issue. I am closing this one.