From ccab02c72332d62c78f376be10f21044b5b226aa Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 19 Jul 2015 02:22:28 -0300 Subject: Memory: Move PAGE_MASK and PAGE_BITS to memory.h --- src/core/memory.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/memory.h') diff --git a/src/core/memory.h b/src/core/memory.h index 418609de0..2a06cc6c3 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -15,6 +15,8 @@ namespace Memory { * be mapped. */ const u32 PAGE_SIZE = 0x1000; +const u32 PAGE_MASK = PAGE_SIZE - 1; +const int PAGE_BITS = 12; /// Physical memory regions as seen from the ARM11 enum : PAddr { -- cgit v1.2.3 From e2c7954be5ccabc7c5f87000db01cef040ca4b47 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 29 Jul 2015 11:54:44 -0300 Subject: Memory: Move address type conversion routines to memory.cpp/h These helpers aren't really part of the kernel, and mem_map.cpp/h is going to be moved there next. --- src/core/memory.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/memory.h') diff --git a/src/core/memory.h b/src/core/memory.h index 2a06cc6c3..e6da3e2a5 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -123,6 +123,17 @@ void WriteBlock(VAddr addr, const u8* data, size_t size); u8* GetPointer(VAddr virtual_address); +/** +* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical +* address. This should be used by services to translate addresses for use by the hardware. +*/ +PAddr VirtualToPhysicalAddress(VAddr addr); + +/** +* Undoes a mapping performed by VirtualToPhysicalAddress(). +*/ +VAddr PhysicalToVirtualAddress(PAddr addr); + /** * Gets a pointer to the memory region beginning at the specified physical address. * -- cgit v1.2.3 From 74d4bc0af1d2f22105bf3c00efcb85613d59cc19 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 5 Aug 2015 21:26:52 -0300 Subject: Kernel: Add more infrastructure to support different memory layouts This adds some structures necessary to support multiple memory regions in the future. It also adds support for different system memory types and the new linear heap mapping at 0x30000000. --- src/core/memory.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/memory.h') diff --git a/src/core/memory.h b/src/core/memory.h index e6da3e2a5..d1d32f0dd 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -107,6 +107,11 @@ enum : VAddr { TLS_AREA_VADDR = 0x1FF82000, TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, + + /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS. + NEW_LINEAR_HEAP_VADDR = 0x30000000, + NEW_LINEAR_HEAP_SIZE = 0x10000000, + NEW_LINEAR_HEAP_VADDR_END = NEW_LINEAR_HEAP_VADDR + NEW_LINEAR_HEAP_SIZE, }; u8 Read8(VAddr addr); -- cgit v1.2.3 From 14eca982f4da2bfd4d2c105bc33722e88e59da5f Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 5 Aug 2015 21:39:53 -0300 Subject: Kernel: Implement svcGetProcessInfo in a basic way This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup. --- src/core/memory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core/memory.h') diff --git a/src/core/memory.h b/src/core/memory.h index d1d32f0dd..c136cbd55 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -105,9 +105,11 @@ enum : VAddr { // hardcoded value. /// Area where TLS (Thread-Local Storage) buffers are allocated. TLS_AREA_VADDR = 0x1FF82000, - TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads + TLS_ENTRY_SIZE = 0x200, + TLS_AREA_SIZE = 300 * TLS_ENTRY_SIZE, // Allows for up to 300 threads TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, + /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS. NEW_LINEAR_HEAP_VADDR = 0x30000000, NEW_LINEAR_HEAP_SIZE = 0x10000000, -- cgit v1.2.3