Browse Source

Add include/arch/properties.h files

Will include architecture-specific properties about the kernel.
Currently they mainly hold macros for calculating where the kernel
starts and ends in physical and virtual memory.
Aaron Lindsay 7 years ago
parent
commit
e69440c698
2 changed files with 68 additions and 0 deletions
  1. 36 0
      arch/arm/include/arch/properties.h
  2. 32 0
      arch/i386/include/arch/properties.h

+ 36 - 0
arch/arm/include/arch/properties.h

@@ -0,0 +1,36 @@
1
+/*
2
+    Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
3
+
4
+    This file is part of Aedrix.
5
+
6
+    This program is free software; you can redistribute it and/or modify
7
+    it under the terms of the GNU General Public License as published by
8
+    the Free Software Foundation; either version 2 of the License, or
9
+    (at your option) any later version.
10
+
11
+    This program is distributed in the hope that it will be useful,
12
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+    GNU General Public License for more details.
15
+
16
+    You should have received a copy of the GNU General Public License along
17
+    with this program; if not, write to the Free Software Foundation, Inc.,
18
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
+ */
20
+
21
+#ifndef PROPERTIES_H
22
+#define PROPERTIES_H
23
+
24
+extern uint32 kernel_start, kernel_end;
25
+extern uint32 tt_base_virtual, tt_base_physical;
26
+#define _kernel_virt_phys_offset ((tt_base_virtual - tt_base_physical)>>2)
27
+
28
+/* Note: this result is shifted left by one because 1<<31 = 2^32/2, and we want to calculate how much space we need for enough translation table entries to map the entire 32-bit range, not just half of it */
29
+#define _init_page_table_size (((uint32)(1<<31)/CONFIG_INIT_PAGE_SIZE)<<1)
30
+
31
+#define kernel_start_physical() (kernel_start_virtual() - _kernel_virt_phys_offset)
32
+#define kernel_end_physical()   (((uint32 *)tt_base_physical) + _init_page_table_size)
33
+#define kernel_start_virtual()  &kernel_start
34
+#define kernel_end_virtual()    (((uint32 *)tt_base_virtual) + _init_page_table_size)
35
+
36
+#endif /* PROPERTIES_H */

+ 32 - 0
arch/i386/include/arch/properties.h

@@ -0,0 +1,32 @@
1
+/*
2
+    Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
3
+
4
+    This file is part of Aedrix.
5
+
6
+    This program is free software; you can redistribute it and/or modify
7
+    it under the terms of the GNU General Public License as published by
8
+    the Free Software Foundation; either version 2 of the License, or
9
+    (at your option) any later version.
10
+
11
+    This program is distributed in the hope that it will be useful,
12
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+    GNU General Public License for more details.
15
+
16
+    You should have received a copy of the GNU General Public License along
17
+    with this program; if not, write to the Free Software Foundation, Inc.,
18
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
+ */
20
+
21
+#ifndef PROPERTIES_H
22
+#define PROPERTIES_H
23
+
24
+extern uint32 kernel_start_phys, kernel_end_phys;
25
+extern uint32 kernel_start, kernel_end;
26
+
27
+#define kernel_start_physical() &kernel_start_phys
28
+#define kernel_end_physical()   &kernel_end_phys
29
+#define kernel_start_virtual()  &kernel_start
30
+#define kernel_end_virtual()    &kernel_end
31
+
32
+#endif /* PROPERTIES_H */