[BACK]Return to fdt_machdep.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / evbarm / fdt

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/evbarm/fdt/fdt_machdep.c between version 1.49 and 1.63

version 1.49, 2018/10/30 21:32:35 version 1.63, 2019/07/15 08:44:33
Line 60  __KERNEL_RCSID(0, "$NetBSD$");
Line 60  __KERNEL_RCSID(0, "$NetBSD$");
 #include <sys/vnode.h>  #include <sys/vnode.h>
 #include <sys/kauth.h>  #include <sys/kauth.h>
 #include <sys/fcntl.h>  #include <sys/fcntl.h>
   #include <sys/uuid.h>
   #include <sys/disk.h>
 #include <sys/md5.h>  #include <sys/md5.h>
   #include <sys/pserialize.h>
   
   #include <net/if.h>
   #include <net/if_dl.h>
   
 #include <dev/cons.h>  #include <dev/cons.h>
 #include <uvm/uvm_extern.h>  #include <uvm/uvm_extern.h>
Line 127  static void fdt_cpu_rootconf(void);
Line 133  static void fdt_cpu_rootconf(void);
 static void fdt_reset(void);  static void fdt_reset(void);
 static void fdt_powerdown(void);  static void fdt_powerdown(void);
   
 static dev_type_cnputc(earlyconsputc);  
 static dev_type_cngetc(earlyconsgetc);  
   
 static struct consdev earlycons = {  
         .cn_putc = earlyconsputc,  
         .cn_getc = earlyconsgetc,  
         .cn_pollc = nullcnpollc,  
 };  
   
 static void  static void
 earlyconsputc(dev_t dev, int c)  earlyconsputc(dev_t dev, int c)
 {  {
Line 145  earlyconsputc(dev_t dev, int c)
Line 142  earlyconsputc(dev_t dev, int c)
 static int  static int
 earlyconsgetc(dev_t dev)  earlyconsgetc(dev_t dev)
 {  {
         return 0;       /* XXX */          return 0;
 }  }
   
   static struct consdev earlycons = {
           .cn_putc = earlyconsputc,
           .cn_getc = earlyconsgetc,
           .cn_pollc = nullcnpollc,
   };
   
 #ifdef VERBOSE_INIT_ARM  #ifdef VERBOSE_INIT_ARM
 #define VPRINTF(...)    printf(__VA_ARGS__)  #define VPRINTF(...)    printf(__VA_ARGS__)
 #else  #else
Line 155  earlyconsgetc(dev_t dev)
Line 158  earlyconsgetc(dev_t dev)
 #endif  #endif
   
 /*  /*
  * ARM: Get the first physically contiguous region of memory.   * Get all of physical memory, including holes.
  * ARM64: Get all of physical memory, including holes.  
  */   */
 static void  static void
 fdt_get_memory(uint64_t *pstart, uint64_t *pend)  fdt_get_memory(uint64_t *pstart, uint64_t *pend)
Line 181  fdt_get_memory(uint64_t *pstart, uint64_
Line 183  fdt_get_memory(uint64_t *pstart, uint64_
                 VPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",                  VPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
                     index, cur_addr, cur_size);                      index, cur_addr, cur_size);
   
 #ifdef __aarch64__  
                 if (cur_addr + cur_size > *pend)                  if (cur_addr + cur_size > *pend)
                         *pend = cur_addr + cur_size;                          *pend = cur_addr + cur_size;
 #else  
                 /* If subsequent entries follow the previous, append them. */  
                 if (*pend == cur_addr)  
                         *pend = cur_addr + cur_size;  
 #endif  
         }          }
 }  }
   
Line 241  fdt_add_dram_blocks(const struct fdt_mem
Line 237  fdt_add_dram_blocks(const struct fdt_mem
 {  {
         BootConfig *bc = arg;          BootConfig *bc = arg;
   
         VPRINTF("  %lx - %lx\n", m->start, m->end - 1);          VPRINTF("  %" PRIx64 " - %" PRIx64 "\n", m->start, m->end - 1);
         bc->dram[bc->dramblocks].address = m->start;          bc->dram[bc->dramblocks].address = m->start;
         bc->dram[bc->dramblocks].pages =          bc->dram[bc->dramblocks].pages =
             (m->end - m->start) / PAGE_SIZE;              (m->end - m->start) / PAGE_SIZE;
Line 255  static struct boot_physmem fdt_physmem[M
Line 251  static struct boot_physmem fdt_physmem[M
 static void  static void
 fdt_add_boot_physmem(const struct fdt_memory *m, void *arg)  fdt_add_boot_physmem(const struct fdt_memory *m, void *arg)
 {  {
         struct boot_physmem *bp = &fdt_physmem[nfdt_physmem++];          const paddr_t saddr = round_page(m->start);
           const paddr_t eaddr = trunc_page(m->end);
   
           VPRINTF("  %" PRIx64 " - %" PRIx64, m->start, m->end - 1);
           if (saddr >= eaddr) {
                   VPRINTF(" skipped\n");
                   return;
           }
           VPRINTF("\n");
   
         VPRINTF("  %lx - %lx\n", m->start, m->end - 1);          struct boot_physmem *bp = &fdt_physmem[nfdt_physmem++];
   
         KASSERT(nfdt_physmem <= MAX_PHYSMEM);          KASSERT(nfdt_physmem <= MAX_PHYSMEM);
   
         bp->bp_start = atop(round_page(m->start));          bp->bp_start = atop(saddr);
         bp->bp_pages = atop(trunc_page(m->end)) - bp->bp_start;          bp->bp_pages = atop(eaddr) - bp->bp_start;
         bp->bp_freelist = VM_FREELIST_DEFAULT;          bp->bp_freelist = VM_FREELIST_DEFAULT;
   
 #ifdef _LP64  #ifdef _LP64
Line 388  fdt_setup_initrd(void)
Line 392  fdt_setup_initrd(void)
   
 #ifdef EFI_RUNTIME  #ifdef EFI_RUNTIME
 static void  static void
 fdt_map_efi_runtime(const char *prop, bool exec)  fdt_map_efi_runtime(const char *prop, enum arm_efirt_mem_type type)
 {  {
         int len;          int len;
   
Line 404  fdt_map_efi_runtime(const char *prop, bo
Line 408  fdt_map_efi_runtime(const char *prop, bo
                 const paddr_t pa = be64toh(map[0]);                  const paddr_t pa = be64toh(map[0]);
                 const vaddr_t va = be64toh(map[1]);                  const vaddr_t va = be64toh(map[1]);
                 const uint64_t sz = be64toh(map[2]);                  const uint64_t sz = be64toh(map[2]);
                 arm_efirt_md_map_range(va, pa, sz, exec);                  VPRINTF("%s: %s %lx-%lx (%lx-%lx)\n", __func__, prop, pa, pa+sz-1, va, va+sz-1);
                   arm_efirt_md_map_range(va, pa, sz, type);
                 map += 3;                  map += 3;
                 len -= 24;                  len -= 24;
         }          }
Line 523  initarm(void *arg)
Line 528  initarm(void *arg)
         fdt_build_bootconfig(memory_start, memory_end);          fdt_build_bootconfig(memory_start, memory_end);
   
 #ifdef EFI_RUNTIME  #ifdef EFI_RUNTIME
         fdt_map_efi_runtime("netbsd,uefi-runtime-code", true);          fdt_map_efi_runtime("netbsd,uefi-runtime-code", ARM_EFIRT_MEM_CODE);
         fdt_map_efi_runtime("netbsd,uefi-runtime-data", false);          fdt_map_efi_runtime("netbsd,uefi-runtime-data", ARM_EFIRT_MEM_DATA);
           fdt_map_efi_runtime("netbsd,uefi-runtime-mmio", ARM_EFIRT_MEM_MMIO);
 #endif  #endif
   
         /* Perform PT build and VM init */          /* Perform PT build and VM init */
Line 540  initarm(void *arg)
Line 546  initarm(void *arg)
         u_int sp = initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, fdt_physmem,          u_int sp = initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, fdt_physmem,
              nfdt_physmem);               nfdt_physmem);
   
         VPRINTF("mpstart\n");          /*
         if (plat->ap_mpstart)           * initarm_common flushes cache if required before AP start
                 plat->ap_mpstart();           */
           error = 0;
           if ((boothowto & RB_MD1) == 0) {
                   VPRINTF("mpstart\n");
                   if (plat->ap_mpstart)
                           error = plat->ap_mpstart();
           }
   
           if (error)
                   return sp;
         /*          /*
          * Now we have APs started the pages used for stacks and L1PT can           * Now we have APs started the pages used for stacks and L1PT can
          * be given to uvm           * be given to uvm
          */           */
         extern char __start__init_memory[], __stop__init_memory[];          extern char const __start__init_memory[];
           extern char const __stop__init_memory[] __weak;
   
         if (__start__init_memory != __stop__init_memory) {          if (__start__init_memory != __stop__init_memory) {
                 const paddr_t spa = KERN_VTOPHYS((vaddr_t)__start__init_memory);                  const paddr_t spa = KERN_VTOPHYS((vaddr_t)__start__init_memory);
                 const paddr_t epa = KERN_VTOPHYS((vaddr_t)__stop__init_memory);                  const paddr_t epa = KERN_VTOPHYS((vaddr_t)__stop__init_memory);
                 const paddr_t spg = atop(spa);                  const paddr_t spg = atop(spa);
                 const paddr_t epg = atop(epa);                  const paddr_t epg = atop(epa);
   
                   VPRINTF("         start %08lx  end %08lx... "
                       "loading in freelist %d\n", spa, epa, VM_FREELIST_DEFAULT);
   
                 uvm_page_physload(spg, epg, spg, epg, VM_FREELIST_DEFAULT);                  uvm_page_physload(spg, epg, spg, epg, VM_FREELIST_DEFAULT);
   
                 VPRINTF("           start %08lx  end %08lx", ptoa(spa), ptoa(epa));  
         }          }
   
         return sp;          return sp;
Line 627  fdt_detect_root_device(device_t dev)
Line 645  fdt_detect_root_device(device_t dev)
         uint8_t buf[DEV_BSIZE];          uint8_t buf[DEV_BSIZE];
         uint8_t hash[16];          uint8_t hash[16];
         const uint8_t *rhash;          const uint8_t *rhash;
         char rootarg[32];          char rootarg[64];
         struct vnode *vp;          struct vnode *vp;
         MD5_CTX md5ctx;          MD5_CTX md5ctx;
         int error, len;          int error, len;
Line 675  fdt_detect_root_device(device_t dev)
Line 693  fdt_detect_root_device(device_t dev)
                 snprintf(rootarg, sizeof(rootarg), " root=%s%c", device_xname(dev), part + 'a');                  snprintf(rootarg, sizeof(rootarg), " root=%s%c", device_xname(dev), part + 'a');
                 strcat(boot_args, rootarg);                  strcat(boot_args, rootarg);
         }          }
   
           if (of_hasprop(chosen, "netbsd,gpt-guid")) {
                   char guidbuf[UUID_STR_LEN];
                   const struct uuid *guid = fdtbus_get_prop(chosen, "netbsd,gpt-guid", &len);
                   if (guid == NULL || len != 16)
                           return;
   
                   uuid_snprintf(guidbuf, sizeof(guidbuf), guid);
                   snprintf(rootarg, sizeof(rootarg), " root=wedge:%s", guidbuf);
                   strcat(boot_args, rootarg);
           }
   
           if (of_hasprop(chosen, "netbsd,gpt-label")) {
                   const char *label = fdtbus_get_string(chosen, "netbsd,gpt-label");
                   if (label == NULL || *label == '\0')
                           return;
   
                   device_t dv = dkwedge_find_by_wname(label);
                   if (dv != NULL)
                           booted_device = dv;
           }
   
           if (of_hasprop(chosen, "netbsd,booted-mac-address")) {
                   const uint8_t *macaddr = fdtbus_get_prop(chosen, "netbsd,booted-mac-address", &len);
                   if (macaddr == NULL || len != 6)
                           return;
                   int s = pserialize_read_enter();
                   struct ifnet *ifp;
                   IFNET_READER_FOREACH(ifp) {
                           if (memcmp(macaddr, CLLADDR(ifp->if_sadl), len) == 0) {
                                   device_t dv = device_find_by_xname(ifp->if_xname);
                                   if (dv != NULL)
                                           booted_device = dv;
                                   break;
                           }
                   }
                   pserialize_read_exit(s);
           }
 }  }
   
 static void  static void

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.63

CVSweb <webmaster@jp.NetBSD.org>