Browse Source

types.h: Add arch_uint_ptr to make comparing native pointer types easier

Aaron Lindsay 7 years ago
parent
commit
ccd5a9025a
5 changed files with 12 additions and 8 deletions
  1. 2 0
      arch/arm/include/arch/types.h
  2. 2 1
      include/arch-generic/types.h
  3. 1 1
      include/atags.h
  4. 1 1
      kernel/atags.c
  5. 6 5
      kernel/mm.c

+ 2 - 0
arch/arm/include/arch/types.h

@@ -19,3 +19,5 @@
19 19
  */
20 20
 
21 21
 #include <arch-generic/types.h>
22
+
23
+#define arch_uint_ptr uint32

+ 2 - 1
include/arch-generic/types.h

@@ -18,4 +18,5 @@
18 18
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19
  */
20 20
 
21
-typedef unsigned int uint32;
21
+typedef unsigned long uint32;
22
+typedef unsigned long long uint64;

+ 1 - 1
include/atags.h

@@ -42,7 +42,7 @@ struct atag_core {
42 42
 
43 43
 struct atag_mem {
44 44
 	uint32 size;	/* size of the area */
45
-	uint32 start;	/* physical start address */
45
+	arch_uint_ptr start;	/* physical start address */
46 46
 };
47 47
 
48 48
 struct atag {

+ 1 - 1
kernel/atags.c

@@ -20,7 +20,7 @@
20 20
 
21 21
 #include <atags.h>
22 22
 
23
-extern uint32 atags_ptr;
23
+extern arch_uint_ptr atags_ptr;
24 24
 
25 25
 int atag_valid(struct atag *a) {
26 26
 	switch (a->tag) {

+ 6 - 5
kernel/mm.c

@@ -21,6 +21,7 @@
21 21
 #include <list.h>
22 22
 #include <mm.h>
23 23
 #include <print.h>
24
+#include <types.h>
24 25
 
25 26
 struct dlist_node mm_free_page_list;
26 27
 
@@ -56,13 +57,13 @@ void mm_add_free_region(void *start, void *end) {
56 57
 		start = (char *)start + MM_PAGE_SIZE;
57 58
 
58 59
 	//make sure both start and end address are aligned to the size of a page
59
-	if ((unsigned int)start % MM_PAGE_SIZE != 0)
60
-		start = (char*)start + (MM_PAGE_SIZE - ((unsigned int)start % MM_PAGE_SIZE));
61
-	if (((unsigned int)end + 1) % MM_PAGE_SIZE != 0)
62
-		end = (char*)end - ((unsigned int)end + 1) % MM_PAGE_SIZE;
60
+	if ((arch_uint_ptr)start % MM_PAGE_SIZE != 0)
61
+		start = (char*)start + (MM_PAGE_SIZE - ((arch_uint_ptr)start % MM_PAGE_SIZE));
62
+	if (((arch_uint_ptr)end + 1) % MM_PAGE_SIZE != 0)
63
+		end = (char*)end - ((arch_uint_ptr)end + 1) % MM_PAGE_SIZE;
63 64
 
64 65
 	if ((char *)end + 1 - (char *)start < MM_PAGE_SIZE<<1) {
65
-		print("Error: Supplied memory area(%x,%x) is smaller than the page size (%d)\n", (unsigned int)start, (unsigned int)end, MM_PAGE_SIZE);
66
+		print("Error: Supplied memory area(%x,%x) is smaller than the page size (%d)\n", (arch_uint_ptr)start, (arch_uint_ptr)end, MM_PAGE_SIZE);
66 67
 		return;
67 68
 	}
68 69