Browse Source

Move atags support to be ARM arch-specific

Aaron Lindsay 7 years ago
parent
commit
62755b8f38
5 changed files with 24 additions and 17 deletions
  1. 0 0
      arch/arm/include/atags.h
  2. 18 0
      arch/arm/kernel/atags.c
  3. 2 1
      arch/arm/kernel/kernel.mk
  4. 3 14
      kernel/init.c
  5. 1 2
      kernel/kernel.mk

include/atags.h → arch/arm/include/atags.h


kernel/atags.c → arch/arm/kernel/atags.c

@@ -19,6 +19,7 @@
19 19
  */
20 20
 
21 21
 #include <atags.h>
22
+#include <mmu.h>
22 23
 
23 24
 extern arch_uint_ptr atags_ptr;
24 25
 
@@ -60,3 +61,20 @@ int _atags_mem_region(struct atag **mem_header, int initialize) {
60 61
 		return -1;
61 62
 	return 0;
62 63
 }
64
+
65
+int detect_memory() {
66
+	struct atag *atags;
67
+	char *lower, *upper;
68
+
69
+	if (atags_first_mem_region(&atags)) {
70
+		return -1;
71
+	}
72
+
73
+	do {
74
+		lower = (char *)atags->data.mem.start;
75
+		upper = lower + atags->data.mem.size - 1;
76
+		declare_memory_region(lower, upper);
77
+	} while (!atags_next_mem_region(&atags));
78
+
79
+	return 0;
80
+}

+ 2 - 1
arch/arm/kernel/kernel.mk

@@ -3,7 +3,8 @@ SUBDIRS :=
3 3
 
4 4
 include $(BASEDIR)/header.mk
5 5
 
6
-OBJS_$(d) := $(d)/mmu.o
6
+OBJS_$(d) := $(d)/atags.o \
7
+	$(d)/mmu.o
7 8
 
8 9
 KOBJS += $(OBJS_$(d))
9 10
 

+ 3 - 14
kernel/init.c

@@ -18,7 +18,6 @@
18 18
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19
  */
20 20
 
21
-#include <atags.h>
22 21
 #include <console.h>
23 22
 #include <framebuffer.h>
24 23
 #include <kmalloc.h>
@@ -94,11 +93,9 @@ void serial_console_init() {
94 93
 //once, and only here
95 94
 void serial_init();
96 95
 void kmalloc_init();
96
+int detect_memory();
97 97
 
98 98
 int main(void) {
99
-	char *lower, *upper;
100
-	struct atag *atags;
101
-
102 99
 	//setup MMU
103 100
 	mmu_reinit();
104 101
 
@@ -114,19 +111,11 @@ int main(void) {
114 111
 	//setup memory subsystems
115 112
 	mm_init();
116 113
 	kmalloc_init();
117
-
118
-	if (atags_first_mem_region(&atags)) {
119
-		print("Error: atags must contain at least one memory region\n");
114
+	if (detect_memory()) {
115
+		print("Error: Failed to detect memory.\n");
120 116
 		return -1;
121 117
 	}
122 118
 
123
-	do {
124
-		lower = (char *)atags->data.mem.start;
125
-		upper = lower + atags->data.mem.size - 1;
126
-		print("atags: physical memory at %x-%x\n", lower, upper);
127
-		declare_memory_region(lower, upper);
128
-	} while (!atags_next_mem_region(&atags));
129
-
130 119
 	init_initcalls();
131 120
 
132 121
 	video_console_init();

+ 1 - 2
kernel/kernel.mk

@@ -3,8 +3,7 @@ SUBDIRS :=
3 3
 
4 4
 include $(BASEDIR)/header.mk
5 5
 
6
-OBJS_$(d) := $(d)/atags.o \
7
-	$(d)/console.o \
6
+OBJS_$(d) := $(d)/console.o \
8 7
 	$(d)/font.o \
9 8
 	$(d)/framebuffer.o \
10 9
 	$(d)/init.o \