aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-11-19 17:55:43 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-11-19 17:55:43 +0100
commitc1f247d0f23173c77a350324ddf0495ffb935860 (patch)
tree4074c12ff53bfe72620b8c5e5288440bf03b1ab5
parent39145f6d1b8c57abe2bc0167b2b413970d0dfdb6 (diff)
downloadrpi-MMU-example-c1f247d0f23173c77a350324ddf0495ffb935860.tar.gz
rpi-MMU-example-c1f247d0f23173c77a350324ddf0495ffb935860.zip
guard against multiple-inclusion of headers
-rw-r--r--cp_regs.h5
-rw-r--r--global.h5
-rw-r--r--paging.h2
-rw-r--r--psr.h4
-rw-r--r--strings.h5
-rw-r--r--translation_table_descriptors.h4
-rw-r--r--uart.h5
7 files changed, 28 insertions, 2 deletions
diff --git a/cp_regs.h b/cp_regs.h
index 2bc6c9f..e5e7063 100644
--- a/cp_regs.h
+++ b/cp_regs.h
@@ -1,5 +1,7 @@
-#include <stdint.h>
+#ifndef CP_REGS_H
+#define CP_REGS_H
+#include <stdint.h>
// SCTLR - System Control Register
@@ -109,3 +111,4 @@ typedef union
} fields;
} TTBR_t;
+#endif // CP_REGS_H
diff --git a/global.h b/global.h
index 02fdedc..b041a65 100644
--- a/global.h
+++ b/global.h
@@ -1,3 +1,6 @@
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
// board type, raspi2
#define RASPI 2
@@ -10,3 +13,5 @@
#define GPIO_BASE 0x20200000
#endif // RASPI == 3 || RASPI == 2
#endif // RASPI == 4
+
+#endif // GLOBAL_H
diff --git a/paging.h b/paging.h
index d38408c..1218fb8 100644
--- a/paging.h
+++ b/paging.h
@@ -3,4 +3,4 @@
void setup_flat_map(void);
-#endif
+#endif // PAGING_H
diff --git a/psr.h b/psr.h
index 6a9d3ea..dfbb878 100644
--- a/psr.h
+++ b/psr.h
@@ -1,3 +1,6 @@
+#ifndef PSR_H
+#define PSR_H
+
#include <stdint.h>
enum execution_mode {
@@ -116,3 +119,4 @@ inline static void set_system_mode(void)
// nop function, that just calls itself a given number of times)
// doesn't have this magical property :(
+#endif // PSR_H
diff --git a/strings.h b/strings.h
index 7721f63..2ceade8 100644
--- a/strings.h
+++ b/strings.h
@@ -1,3 +1,6 @@
+#ifndef STRINGS_H
+#define STRINGS_H
+
#include <stdint.h>
void uint32_to_bits(uint32_t number, char *buf)
@@ -7,3 +10,5 @@ void uint32_to_bits(uint32_t number, char *buf)
buf[32] = '\0';
}
+
+#endif // STRINGS_H
diff --git a/translation_table_descriptors.h b/translation_table_descriptors.h
index b73f594..981c3c7 100644
--- a/translation_table_descriptors.h
+++ b/translation_table_descriptors.h
@@ -1,3 +1,6 @@
+#ifndef TRANSLATION_TABLE_DESCRIPTORS_H
+#define TRANSLATION_TABLE_DESCRIPTORS_H
+
#include <stdint.h>
// ARM lets you choose between 32-bit abd 64-bit translation table
@@ -174,3 +177,4 @@ typedef union
// 0b11 should not be used
#define SHORT_DESCRIPTOR_RESERVED 0b11
+#endif // TRANSLATION_TABLE_DESCRIPTORS_H
diff --git a/uart.h b/uart.h
index 6430cb1..ec29d47 100644
--- a/uart.h
+++ b/uart.h
@@ -1,3 +1,6 @@
+#ifndef UART_H
+#define UART_H
+
#include <stddef.h>
#include <stdint.h>
#include <global.h>
@@ -39,3 +42,5 @@ void uart_init();
void uart_putc(unsigned char c);
unsigned char uart_getc();
void uart_puts(const char* str);
+
+#endif // UART_H