armv7_helloworld

simple bare metal ARMv7 example
git clone https://0xdd.org/code/armv7_helloworld.git
Log | Files | Refs | README | LICENSE

main.c (602B)


      1 /*
      2 2018 David DiPaola
      3 licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
      4 */
      5 
      6 #define pragma_section(name) __attribute__((section(name)))
      7 
      8 typedef unsigned int u32;
      9 
     10 /* PL011 registers (see DDI0183:3.2) */
     11 struct uart_pl011 {
     12 	volatile u32 dr;  /* 0x000 */
     13 };
     14 
     15 pragma_section("SECTION_IO_UART0") struct uart_pl011 uart0;
     16 
     17 static void
     18 print(const char * s) {
     19 	char c;
     20 	for (;;) {
     21 		c = *s;
     22 		if (c == '\0') break;
     23 		uart0.dr = c;
     24 		s++;
     25 	}
     26 }
     27 
     28 static void
     29 println(const char * s) {
     30 	print(s);
     31 	print("\r\n");
     32 }
     33 
     34 void
     35 main(void) {
     36 	for (;;) {
     37 		println("hi");
     38 	}
     39 }
     40