arm: clang-format

This commit is contained in:
Paul Mathieu 2022-05-16 20:57:51 -07:00
parent 932b8d4582
commit 574e48474b
4 changed files with 23 additions and 19 deletions

9
arm/.clang-format Normal file
View File

@ -0,0 +1,9 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: Google
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left

View File

@ -3,14 +3,9 @@
extern "C" int main(); extern "C" int main();
extern uint32_t _bss_begin, _bss_end, _initial_stack_pointer; extern uint32_t _bss_begin, _bss_end, _initial_stack_pointer;
__attribute__((section(".app_init"))) __attribute__((section(".app_init"), used)) void AppInit() {
void AppInit() {
*(uint32_t*)(0x40000000) = 0; *(uint32_t*)(0x40000000) = 0;
asm ("mov sp, %0" asm("mov sp, %0" : : "r"(&_initial_stack_pointer) :);
:
: "r" (&_initial_stack_pointer)
:
);
// clear .bss // clear .bss
for (uint32_t* ptr = &_bss_begin; ptr < &_bss_end; ptr++) { for (uint32_t* ptr = &_bss_begin; ptr < &_bss_end; ptr++) {
@ -19,5 +14,6 @@ void AppInit() {
main(); main();
while(true) {} while (true) {
}
} }

View File

@ -7,13 +7,12 @@ namespace {
uint8_t UartRead() { uint8_t UartRead() {
uint8_t c; uint8_t c;
while (XUartLite_Recv(uart0, &c, 1) < 1) {} while (XUartLite_Recv(uart0, &c, 1) < 1) {
}
return c; return c;
} }
void UartWrite(uint8_t c) { void UartWrite(uint8_t c) { XUartLite_Send(uart0, &c, 1); }
XUartLite_Send(uart0, &c, 1);
}
uint32_t UartRead32() { uint32_t UartRead32() {
uint32_t val = 0; uint32_t val = 0;

View File

@ -18,13 +18,13 @@ void ResetHandler() {
main(); main();
while(true) {} while (true) {
}
} }
} // namespace } // namespace
__attribute__((section(".vector_table"), used)) __attribute__((section(".vector_table"), used)) uint32_t vector_table[16] = {
uint32_t vector_table[16] = {
[StackPointer] = reinterpret_cast<uint32_t>(&_initial_stack_pointer), [StackPointer] = reinterpret_cast<uint32_t>(&_initial_stack_pointer),
[Reset] = reinterpret_cast<uint32_t>(ResetHandler), [Reset] = reinterpret_cast<uint32_t>(ResetHandler),
}; };