GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_device_stack_transfer_abort.c Lines: 11 11 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Device Stack                                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
#define UX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "ux_api.h"
29
#include "ux_device_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_device_stack_transfer_abort                     PORTABLE C      */
37
/*                                                           6.1.10       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function aborts a pending transfer request that has been       */
45
/*    previously submitted. This function only cancels a specific         */
46
/*    transfer request.                                                   */
47
/*                                                                        */
48
/*    The call back to the function will have the                         */
49
/*    UX_TRANSFER_STATUS_ABORT status                                     */
50
/*                                                                        */
51
/*  INPUT                                                                 */
52
/*                                                                        */
53
/*    transfer_request                      Pointer to transfer request   */
54
/*    completion_code                       Completion code               */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    Completion Status                                                   */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _ux_utility_semaphore_put             Put semaphore                 */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application                                                         */
67
/*    Device Stack                                                        */
68
/*                                                                        */
69
/**************************************************************************/
70
2124
UINT  _ux_device_stack_transfer_abort(UX_SLAVE_TRANSFER *transfer_request, ULONG completion_code)
71
{
72
73
UX_INTERRUPT_SAVE_AREA
74
75
UX_SLAVE_DCD    *dcd;
76
77
    UX_PARAMETER_NOT_USED(completion_code);
78
79
    /* If trace is enabled, insert this event into the trace buffer.  */
80
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_TRANSFER_ABORT, transfer_request, completion_code, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0)
81
82
    /* Get the pointer to the DCD.  */
83
2124
    dcd =  &_ux_system_slave -> ux_system_slave_dcd;
84
85
    /* Sets the completion code due to bus reset.  */
86
2124
    transfer_request -> ux_slave_transfer_request_completion_code = completion_code;
87
88
    /* Ensure we're not preempted by the transfer completion ISR.  */
89
2124
    UX_DISABLE
90
91
    /* It's possible the transfer already completed. Ensure it hasn't before doing the abort.  */
92
2124
    if (transfer_request -> ux_slave_transfer_request_status == UX_TRANSFER_STATUS_PENDING)
93
    {
94
95
        /* Call the DCD if necessary for cleaning up the pending transfer.  */
96
352
        dcd -> ux_slave_dcd_function(dcd, UX_DCD_TRANSFER_ABORT, (VOID *) transfer_request);
97
98
        /* Restore interrupts. Note that the transfer request should not be modified now.  */
99
352
        UX_RESTORE
100
101
        /* We need to set the completion code for the transfer to aborted. Note
102
           that the transfer request function cannot simultaneously modify this
103
           because if the transfer was pending, then the transfer's thread is
104
           currently waiting for it to complete.  */
105
352
        transfer_request -> ux_slave_transfer_request_status =  UX_TRANSFER_STATUS_ABORT;
106
107
        /* Wake up the device driver who is waiting on the semaphore.  */
108
352
        _ux_device_semaphore_put(&transfer_request -> ux_slave_transfer_request_semaphore);
109
    }
110
    else
111
    {
112
113
        /* Restore interrupts.  */
114
1772
        UX_RESTORE
115
    }
116
117
    /* This function never fails.  */
118
2124
    return(UX_SUCCESS);
119
}
120