Rev 3386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4153 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup mips32mm |
29 | /** @addtogroup mips32mm |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
Line 38... | Line 38... | ||
38 | #include <interrupt.h> |
38 | #include <interrupt.h> |
39 | #include <mm/frame.h> |
39 | #include <mm/frame.h> |
40 | #include <mm/asid.h> |
40 | #include <mm/asid.h> |
41 | #include <config.h> |
41 | #include <config.h> |
42 | #include <arch/drivers/msim.h> |
42 | #include <arch/drivers/msim.h> |
43 | #include <arch/drivers/serial.h> |
- | |
44 | #include <print.h> |
43 | #include <print.h> |
45 | 44 | ||
46 | #define ZERO_PAGE_MASK TLB_PAGE_MASK_256K |
45 | #define ZERO_PAGE_MASK TLB_PAGE_MASK_256K |
47 | #define ZERO_FRAMES 2048 |
46 | #define ZERO_FRAMES 2048 |
48 | #define ZERO_PAGE_WIDTH 18 /* 256K */ |
47 | #define ZERO_PAGE_WIDTH 18 /* 256K */ |
49 | #define ZERO_PAGE_SIZE (1 << ZERO_PAGE_WIDTH) |
48 | #define ZERO_PAGE_SIZE (1 << ZERO_PAGE_WIDTH) |
50 | #define ZERO_PAGE_ASID ASID_INVALID |
49 | #define ZERO_PAGE_ASID ASID_INVALID |
51 | #define ZERO_PAGE_TLBI 0 |
50 | #define ZERO_PAGE_TLBI 0 |
52 | #define ZERO_PAGE_ADDR 0 |
51 | #define ZERO_PAGE_ADDR 0 |
53 | #define ZERO_PAGE_OFFSET (ZERO_PAGE_SIZE / sizeof(uint32_t) - 1) |
52 | #define ZERO_PAGE_OFFSET (ZERO_PAGE_SIZE / sizeof(uint32_t) - 1) |
54 | #define ZERO_PAGE_VALUE (((volatile uint32_t *) ZERO_PAGE_ADDR)[ZERO_PAGE_OFFSET]) |
53 | #define ZERO_PAGE_VALUE (((volatile uint32_t *) ZERO_PAGE_ADDR)[ZERO_PAGE_OFFSET]) |
55 | 54 | ||
- | 55 | #define ZERO_PAGE_VALUE_KSEG1(frame) \ |
|
56 | #define ZERO_PAGE_VALUE_KSEG1(frame) (((volatile uint32_t *) (0xa0000000 + (frame << ZERO_PAGE_WIDTH)))[ZERO_PAGE_OFFSET]) |
56 | (((volatile uint32_t *) (0xa0000000 + (frame << ZERO_PAGE_WIDTH)))[ZERO_PAGE_OFFSET]) |
57 | 57 | ||
58 | #define MAX_REGIONS 32 |
58 | #define MAX_REGIONS 32 |
59 | 59 | ||
60 | typedef struct { |
60 | typedef struct { |
61 | pfn_t start; |
61 | pfn_t start; |
62 | pfn_t count; |
62 | pfn_t count; |
63 | } phys_region_t; |
63 | } phys_region_t; |
64 | 64 | ||
65 | static count_t phys_regions_count = 0; |
65 | static count_t phys_regions_count = 0; |
66 | static phys_region_t phys_regions[MAX_REGIONS]; |
66 | static phys_region_t phys_regions[MAX_REGIONS]; |
67 | 67 | ||
68 | - | ||
69 | /** Check whether frame is available |
68 | /** Check whether frame is available |
70 | * |
69 | * |
71 | * Returns true if given frame is generally available for use. |
70 | * Returns true if given frame is generally available for use. |
72 | * Returns false if given frame is used for physical memory |
71 | * Returns false if given frame is used for physical memory |
73 | * mapped devices and cannot be used. |
72 | * mapped devices and cannot be used. |
74 | * |
73 | * |
75 | */ |
74 | */ |
76 | static bool frame_available(pfn_t frame) |
75 | static bool frame_available(pfn_t frame) |
77 | { |
76 | { |
78 | #if MACHINE == msim |
77 | #ifdef MACHINE_msim |
79 | /* MSIM device (dprinter) */ |
78 | /* MSIM device (dprinter) */ |
80 | if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH)) |
79 | if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH)) |
81 | return false; |
80 | return false; |
82 | 81 | ||
83 | /* MSIM device (dkeyboard) */ |
82 | /* MSIM device (dkeyboard) */ |
84 | if (frame == (KA2PA(MSIM_KBD_ADDRESS) >> ZERO_PAGE_WIDTH)) |
83 | if (frame == (KA2PA(MSIM_KBD_ADDRESS) >> ZERO_PAGE_WIDTH)) |
85 | return false; |
84 | return false; |
86 | #endif |
85 | #endif |
87 | 86 | ||
88 | #if MACHINE == simics |
- | |
89 | /* Simics device (serial line) */ |
- | |
90 | if (frame == (KA2PA(SERIAL_ADDRESS) >> ZERO_PAGE_WIDTH)) |
- | |
91 | return false; |
- | |
92 | #endif |
- | |
93 | - | ||
94 | #if (MACHINE == lgxemul) || (MACHINE == bgxemul) |
87 | #if defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) |
95 | /* gxemul devices */ |
88 | /* gxemul devices */ |
96 | if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, |
89 | if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, |
97 | 0x10000000, MB2SIZE(256))) |
90 | 0x10000000, MB2SIZE(256))) |
98 | return false; |
91 | return false; |
99 | #endif |
92 | #endif |
Line 216... | Line 209... | ||
216 | avail = false; |
209 | avail = false; |
217 | else { |
210 | else { |
218 | ZERO_PAGE_VALUE = 0xdeadbeef; |
211 | ZERO_PAGE_VALUE = 0xdeadbeef; |
219 | if (ZERO_PAGE_VALUE != 0xdeadbeef) |
212 | if (ZERO_PAGE_VALUE != 0xdeadbeef) |
220 | avail = false; |
213 | avail = false; |
221 | #if (MACHINE == lgxemul) || (MACHINE == bgxemul) |
214 | #if defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) |
222 | else { |
215 | else { |
223 | ZERO_PAGE_VALUE_KSEG1(frame) = 0xaabbccdd; |
216 | ZERO_PAGE_VALUE_KSEG1(frame) = 0xaabbccdd; |
224 | if (ZERO_PAGE_VALUE_KSEG1(frame) != 0xaabbccdd) |
217 | if (ZERO_PAGE_VALUE_KSEG1(frame) != 0xaabbccdd) |
225 | avail = false; |
218 | avail = false; |
226 | } |
219 | } |