Print this page
fakebop: use a memlist to keep track of physical memory


  71  */
  72 #define FAKEBOP_ALLOC_SIZE      (16 * 1024 * 1024)
  73 
  74 static size_t bop_alloc_scratch_size;
  75 static uintptr_t bop_alloc_scratch_next;        /* Next scratch address */
  76 static uintptr_t bop_alloc_scratch_last;        /* Last scratch address */
  77 
  78 static uintptr_t bop_alloc_pnext;               /* Next paddr */
  79 static uintptr_t bop_alloc_plast;               /* cross this paddr and panic */
  80 
  81 #define BI_HAS_RAMDISK  0x1
  82 
  83 /*
  84  * TODO Generalize this
  85  * This is the set of information tha we want to gather from the various atag
  86  * headers. This is simple and naive and will need to evolve as we have
  87  * additional boards beyond just the RPi.
  88  */
  89 typedef struct bootinfo {
  90         uint_t          bi_flags;
  91         uint32_t        bi_memsize;
  92         uint32_t        bi_memstart;
  93         char            *bi_cmdline;
  94         uint32_t        bi_ramdisk;
  95         uint32_t        bi_ramsize;
  96 } bootinfo_t;
  97 
  98 static bootinfo_t bootinfo;     /* Simple set of boot information */
  99 
 100 static struct boot_syscalls bop_sysp = {
 101         bcons_getchar,
 102         bcons_putchar,
 103         bcons_ischar,
 104 };
 105 
 106 /*
 107  * stuff to store/report/manipulate boot property settings.
 108  */
 109 typedef struct bootprop {
 110         struct bootprop *bp_next;
 111         char *bp_name;
 112         uint_t bp_vlen;


 358         bootinfo_t *bp = &bootinfo;
 359         boolean_t got_mem = B_FALSE;
 360 
 361         bp->bi_flags = 0;
 362         while (ahp != NULL) {
 363                 switch (ahp->ah_tag) {
 364                 case ATAG_MEM:
 365                         amp = (atag_mem_t *)ahp;
 366                         /*
 367                          * We may actually get more than one ATAG_MEM if the
 368                          * system has discontiguous physical memory
 369                          */
 370                         if (got_mem) {
 371                                 bop_printf(NULL, "found multiple ATAG_MEM\n");
 372                                 bop_printf(NULL, "ignoring: %#x - %#x\n",
 373                                     amp->am_start, amp->am_start +
 374                                     amp->am_size - 1);
 375                                 break;
 376                         }
 377 
 378                         bp->bi_memsize = amp->am_size;
 379                         bp->bi_memstart = amp->am_start;


 380                         got_mem = B_TRUE;
 381                         break;
 382                 case ATAG_CMDLINE:
 383                         alp = (atag_cmdline_t *)ahp;
 384                         bp->bi_cmdline = alp->al_cmdline;
 385                         break;
 386                 case ATAG_ILLUMOS_STATUS:
 387                         aisp = (atag_illumos_status_t *)ahp;
 388                         bp->bi_ramdisk = aisp->ais_archive;
 389                         bp->bi_ramsize = aisp->ais_archivelen;
 390                         bp->bi_flags |= BI_HAS_RAMDISK;
 391                         break;
 392                 default:
 393                         break;
 394                 }
 395                 ahp = atag_next(ahp);
 396         }
 397 }
 398 
 399 /*




  71  */
  72 #define FAKEBOP_ALLOC_SIZE      (16 * 1024 * 1024)
  73 
  74 static size_t bop_alloc_scratch_size;
  75 static uintptr_t bop_alloc_scratch_next;        /* Next scratch address */
  76 static uintptr_t bop_alloc_scratch_last;        /* Last scratch address */
  77 
  78 static uintptr_t bop_alloc_pnext;               /* Next paddr */
  79 static uintptr_t bop_alloc_plast;               /* cross this paddr and panic */
  80 
  81 #define BI_HAS_RAMDISK  0x1
  82 
  83 /*
  84  * TODO Generalize this
  85  * This is the set of information tha we want to gather from the various atag
  86  * headers. This is simple and naive and will need to evolve as we have
  87  * additional boards beyond just the RPi.
  88  */
  89 typedef struct bootinfo {
  90         uint_t          bi_flags;


  91         char            *bi_cmdline;
  92         uint32_t        bi_ramdisk;
  93         uint32_t        bi_ramsize;
  94 } bootinfo_t;
  95 
  96 static bootinfo_t bootinfo;     /* Simple set of boot information */
  97 
  98 static struct boot_syscalls bop_sysp = {
  99         bcons_getchar,
 100         bcons_putchar,
 101         bcons_ischar,
 102 };
 103 
 104 /*
 105  * stuff to store/report/manipulate boot property settings.
 106  */
 107 typedef struct bootprop {
 108         struct bootprop *bp_next;
 109         char *bp_name;
 110         uint_t bp_vlen;


 356         bootinfo_t *bp = &bootinfo;
 357         boolean_t got_mem = B_FALSE;
 358 
 359         bp->bi_flags = 0;
 360         while (ahp != NULL) {
 361                 switch (ahp->ah_tag) {
 362                 case ATAG_MEM:
 363                         amp = (atag_mem_t *)ahp;
 364                         /*
 365                          * We may actually get more than one ATAG_MEM if the
 366                          * system has discontiguous physical memory
 367                          */
 368                         if (got_mem) {
 369                                 bop_printf(NULL, "found multiple ATAG_MEM\n");
 370                                 bop_printf(NULL, "ignoring: %#x - %#x\n",
 371                                     amp->am_start, amp->am_start +
 372                                     amp->am_size - 1);
 373                                 break;
 374                         }
 375 
 376                         bootop.boot_mem.physinstalled.ml_address = amp->am_start;
 377                         bootop.boot_mem.physinstalled.ml_size = amp->am_size;
 378                         bootop.boot_mem.physinstalled.ml_prev = NULL;
 379                         bootop.boot_mem.physinstalled.ml_next = NULL;
 380                         got_mem = B_TRUE;
 381                         break;
 382                 case ATAG_CMDLINE:
 383                         alp = (atag_cmdline_t *)ahp;
 384                         bp->bi_cmdline = alp->al_cmdline;
 385                         break;
 386                 case ATAG_ILLUMOS_STATUS:
 387                         aisp = (atag_illumos_status_t *)ahp;
 388                         bp->bi_ramdisk = aisp->ais_archive;
 389                         bp->bi_ramsize = aisp->ais_archivelen;
 390                         bp->bi_flags |= BI_HAS_RAMDISK;
 391                         break;
 392                 default:
 393                         break;
 394                 }
 395                 ahp = atag_next(ahp);
 396         }
 397 }
 398 
 399 /*