⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscall.s

📁 一个小型的嵌入式操作系统内核,可用于多种硬件平台
💻 S
📖 第 1 页 / 共 2 页
字号:
    swi 11
    mov pc,lr

;/**************************************************************************************************
;* Description:      Allocate a memory from a specified heap.
;* Parameters:       heapID      Specifies the heap ID
;                    size        Specifies the block size to allocate in unit of byte
;* return values:    None zero   The allocated block's start address
;                    Zero        No memory is available
;**************************************************************************************************/
edl_heapAlloc
    swi 12
    mov pc,lr

;/**************************************************************************************************
;* Description:      Free a memory block.
;* Parameters:       heapID      Specifies the heap ID
;                    addr        Pointer to the memory block to be freed
;* return values:    ERR_INVALID_PARAM       Invalid parameter
;                    ERR_SUCCESS             OK
;**************************************************************************************************/
edl_heapFree
    swi 13
    mov pc,lr

;/**************************************************************************************************
;* Description:      Reallocate a memory block.
;* Parameters:       heapID      Specifies the heap ID
;                    addr        Pointer to the old memory block's start address
;                    size        Specifies the block size to reallocate
;* return values:    None zero   The allocated block's start address
;                    Zero        No memory is available
;**************************************************************************************************/
edl_heapReAlloc
    swi 14
    mov pc,lr

;/**************************************************************************************************
;* Description:      Create a semaphore
;* Parameters:      name                    Pointer to the semaphore name, which uniquely identify
;                                                     the semaphore. 
;                    flags                   Attribute value,The follwoing specifies the flags 
;                                            SEM_FIFO   The waiting task will be queued by FIFO, 
;                                            SEM_PRIO   The waiting task will be queued by priority.
;                                            SEM_CREATE Create a semaphore
;                                            SEM_OPEN   Open an existent semaphore
;                    count                   Specifies semaphore initial instance count
;                    semID                   Pointer to a variable to the semaphore ID
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_ALLOC_SCB_FAIL      Failed to allocate the Semophore Control Block
;                    ERR_OUT_OF_SEM_MAX_NUM  Out of max Semaphore number
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_createSem
    swi 15
    mov pc,lr

;/**************************************************************************************************
;* Description:      Delete a semaphore
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_TASK_IS_WAITING     There are tasks are waiting for this semaphore to be 
;                                            released.
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_deleteSem
    swi 16
    mov pc,lr


;/**************************************************************************************************
;* Description:      Get a semaphore 
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_SUCCESS             OK.
;                    ERR_NO_SEM              No semaphore is avalaible.
;                    ERR_TIMEOUT             Time is out.
;**************************************************************************************************/
edl_getSem
    swi 17
    mov pc,lr


;/**************************************************************************************************
;* Description:      Release a semaphore
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_releaseSem
    swi 18
    mov pc,lr


;/**************************************************************************************************
;* Description:      Send a buffer of data to a specified task.
;* Parameters:       desTskID                The destination task's ID to receive the message
;                    flags                   Specifies  how the message will be inserted, there are
;                                            two options, MSG_FIFO and MSG_PRIO
;                    buf                     pointer to a buffer of data to be sent
;                    bufLen                  buffer length in unit of byte
;                    block                   BOOL value to specifies whether the sending task needs
;                                            to be blocked before the message is processed.
;* return values:    ERR_MEM_ALLOC_FAIL       Failed to allocate message block
;                    ERR_SUCCESS              OK
;**************************************************************************************************/
edl_sendMsg
    STMFD   SP!, {R4,R5}    ; Save the registers modified in the function
    add     r5,sp,#8        
    LDMFD   r5, {R4}        ; Get the fifth parameter from stack and assign it to r4 as the fifth 
                            ; parameter in system call
    swi 19                   ; Software interrupt
    LDMFD   SP!, {R4,R5}    ; Restore the registers modified in the function
    mov pc,lr

;/**************************************************************************************************
;* Description:      Wait on a message
;* Parameters:       timeOut             Specifies timeout interval in unit of timer tick, if it is
;                                        assigned with INFINITE_TIME, the function will not return 
;                                        untill it get message
;                    flags               Specifies whether the message should be removed after being
;                                        accessed.there are two options
;                                        MSG_PEEK        Keep the message
;                                        MSG_DEQUEUE     Remove the message
;                    buf                 Pointer to buffer that stores the received message
;                    bufLen              Pointer to a variable that stores the received message length
;                                        in unit of byte
;                    msgLen              Pointer to a variable to store the received message's length
;                    srcTskID            Pointer to a variable to store the task's ID which sends the
;                                        message  
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_NO_MESSAGE          no buffer message is avalaible
;                    ERR_BUF_OVERFLOW        Buffer size is too small to store the received message
;                    ERR_SUCCESS             OK.
;                    ERR_TIMEOUT             time is out
;**************************************************************************************************/
edl_getMsg
    STMFD   SP!, {R4,R5,R6}    ; Save the registers modified in the function
    add     r6,sp,#12        
    LDMFD   r6, {R5,R4}        ; Get the fifth and sixth parameters from stack and assign it to r4 and 
                               ; r5 as the fifth and sixth parameters in system call
    swi 20                  ; Software interrupt
    LDMFD   SP!, {R4,R5,R6} ; Restore the registers modified in the function
    mov pc,lr



;/**************************************************************************************************
;* Description:      Create a mutex
;* Parameters:       name                    Pointer to the Mutex name, which uniquely identify
;                                            the semaphore.
;                    flags                   Attribute value,The follwoing specifies the flags 
;                                            MU_CREATE Create a Mutex
;                                            MU_OPEN   Open an existing Mutex
;                    protocol                Specifies protocol the mutually exclusive semaphore takes
;                                            , the following list two options:
;                                            PRIO_INHERIT_PROT       Priority Inheritance Protocol
;                                            PRIO_CEILING_PROT       Priority Ceiling Protocol
;                    prioCeiling             Priority ceiling used in priority ceiling protocol. It 
;                                            specifies the highest priority of the tasks which will
;                                            contend to obtain the resource. This argument is ignored
;                                            in other protocol, just fill it with zero. 
;                    muID                    Points to a variable storing the Mutex ID.
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_ALLOC_MCB_FAIL      Failed to allocate the Mutex Control Block
;                    ERR_OUT_OF_MU_MAX_NUM   Out of max mutex number
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_createMutex
    STMFD   SP!, {R4,R5}    ; Save the registers modified in the function
    add     r5,sp,#8        
    LDMFD   r5, {R4}        ; Get the fifth parameter from stack and assign it to r4 as the fifth 
                            ; parameter in system call
    swi 21                   ; Software interrupt
    LDMFD   SP!, {R4,R5}    ; Restore the registers modified in the function
    mov pc,lr


;/**************************************************************************************************
;* Description:      Delete a Mutex
;* Parameters:       r0                      Mutex ID
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_TASK_IS_WAITING     There are tasks are waiting for this semaphore to be 
;                                            released.
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_deleteMutex
    swi 22
    mov pc,lr

;/**************************************************************************************************
;* Description:      Lock a mutually exclusively semaphore.
;* Parameters:       muID                    Mutex ID
;                    timeout                 Specifies the timeout in unit of timer tick
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_PROT_ERROR          Protocol error.
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_getMutex
    swi 23
    mov pc,lr

;/**************************************************************************************************
;* Description:      Unlock a mutex 
;* Parameters:       r0                      Mutex ID
;* return values:    ERR_INVALID_PARAM       Invalid parameter.
;                    ERR_PROT_ERROR          Protocol error.
;                    ERR_SUCCESS             OK.
;**************************************************************************************************/
edl_releaseMutex
    swi 24
    mov pc,lr

    END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -