~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/loongarch/kernel/mem.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  4  */
  5 #include <linux/efi.h>
  6 #include <linux/initrd.h>
  7 #include <linux/memblock.h>
  8 
  9 #include <asm/bootinfo.h>
 10 #include <asm/loongson.h>
 11 #include <asm/sections.h>
 12 
 13 void __init memblock_init(void)
 14 {
 15         u32 mem_type;
 16         u64 mem_start, mem_end, mem_size;
 17         efi_memory_desc_t *md;
 18 
 19         /* Parse memory information */
 20         for_each_efi_memory_desc(md) {
 21                 mem_type = md->type;
 22                 mem_start = md->phys_addr;
 23                 mem_size = md->num_pages << EFI_PAGE_SHIFT;
 24                 mem_end = mem_start + mem_size;
 25 
 26                 switch (mem_type) {
 27                 case EFI_LOADER_CODE:
 28                 case EFI_LOADER_DATA:
 29                 case EFI_BOOT_SERVICES_CODE:
 30                 case EFI_BOOT_SERVICES_DATA:
 31                 case EFI_PERSISTENT_MEMORY:
 32                 case EFI_CONVENTIONAL_MEMORY:
 33                         memblock_add(mem_start, mem_size);
 34                         if (max_low_pfn < (mem_end >> PAGE_SHIFT))
 35                                 max_low_pfn = mem_end >> PAGE_SHIFT;
 36                         break;
 37                 case EFI_PAL_CODE:
 38                 case EFI_UNUSABLE_MEMORY:
 39                 case EFI_ACPI_RECLAIM_MEMORY:
 40                         memblock_add(mem_start, mem_size);
 41                         fallthrough;
 42                 case EFI_RESERVED_TYPE:
 43                 case EFI_RUNTIME_SERVICES_CODE:
 44                 case EFI_RUNTIME_SERVICES_DATA:
 45                 case EFI_MEMORY_MAPPED_IO:
 46                 case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
 47                         memblock_reserve(mem_start, mem_size);
 48                         break;
 49                 }
 50         }
 51 
 52         memblock_set_current_limit(PFN_PHYS(max_low_pfn));
 53 
 54         /* Reserve the first 2MB */
 55         memblock_reserve(PHYS_OFFSET, 0x200000);
 56 
 57         /* Reserve the kernel text/data/bss */
 58         memblock_reserve(__pa_symbol(&_text),
 59                          __pa_symbol(&_end) - __pa_symbol(&_text));
 60 
 61         memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
 62         memblock_set_node(0, PHYS_ADDR_MAX, &memblock.reserved, 0);
 63 }
 64 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php