forked from michahoiting/rv-link
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dlink.c
121 lines (101 loc) · 4.34 KB
/
dlink.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (c) 2019 [email protected]
* Copyright (c) 2020, Micha Hoiting <[email protected]>
* Copyright (c) 2022 Nuclei Limited. All rights reserved.
*
* Dlink is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*/
#include "port.h"
#include "gdb-server.h"
#include "gdb-packet.h"
TaskHandle_t gdb_server_xHandle = NULL;
void gdb_server_vTask(void* pvParameters)
{
gdb_packet_init();
gdb_server_init();
rv_board_init();
for (;;) {
gdb_server_poll();
}
}
int main(void)
{
BaseType_t xReturned;
printf("DLink Firmware Version %s\n", DLINK_FIRMWARE_VERSION);
#if defined(CI_JOB_ID) && CI_JOB_ID > 0
printf("DLink Build Via CI, JOB ID is %u\n", CI_JOB_ID);
#endif
xReturned = xTaskCreate(gdb_server_vTask, /* Function that implements the task. */
"gdb_server", /* Text name for the task. */
512, /* Stack size in words, not bytes. */
NULL, /* Parameter passed into the task. */
4, /* Priority at which the task is created. */
&gdb_server_xHandle); /* Used to pass out the created task's handle. */
if(xReturned != pdPASS) {
/* error msg */
vTaskDelete(gdb_server_xHandle);
}
vTaskStartScheduler();
while (1);
}
void vApplicationTickHook(void)
{
// BaseType_t xHigherPriorityTaskWoken = pdFALSE;
/* The RTOS tick hook function is enabled by setting configUSE_TICK_HOOK to
1 in FreeRTOSConfig.h.
"Give" the semaphore on every 500th tick interrupt. */
/* If xHigherPriorityTaskWoken is pdTRUE then a context switch should
normally be performed before leaving the interrupt (because during the
execution of the interrupt a task of equal or higher priority than the
running task was unblocked). The syntax required to context switch from
an interrupt is port dependent, so check the documentation of the port you
are using.
In this case, the function is running in the context of the tick interrupt,
which will automatically check for the higher priority task to run anyway,
so no further action is required. */
}
/*-----------------------------------------------------------*/
void vApplicationMallocFailedHook(void)
{
/* The malloc failed hook is enabled by setting
configUSE_MALLOC_FAILED_HOOK to 1 in FreeRTOSConfig.h.
Called if a call to pvPortMalloc() fails because there is insufficient
free memory available in the FreeRTOS heap. pvPortMalloc() is called
internally by FreeRTOS API functions that create tasks, queues, software
timers, and semaphores. The size of the FreeRTOS heap is set by the
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
while (1);
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook(TaskHandle_t xTask, char* pcTaskName)
{
/* Run time stack overflow checking is performed if
configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. pxCurrentTCB can be
inspected in the debugger if the task name passed into this function is
corrupt. */
while (1);
}
/*-----------------------------------------------------------*/
extern UBaseType_t uxCriticalNesting;
void vApplicationIdleHook(void)
{
// volatile size_t xFreeStackSpace;
/* The idle task hook is enabled by setting configUSE_IDLE_HOOK to 1 in
FreeRTOSConfig.h.
This function is called on each cycle of the idle task. In this case it
does nothing useful, other than report the amount of FreeRTOS heap that
remains unallocated. */
/* By now, the kernel has allocated everything it is going to, so
if there is a lot of heap remaining unallocated then
the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be
reduced accordingly. */
}