Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    9259 libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c
          +++ new/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27      -/*        All Rights Reserved   */
       27 +/*      All Rights Reserved     */
  28   28  
  29   29  /*
  30   30   * University Copyright- Copyright (c) 1982, 1986, 1988
  31   31   * The Regents of the University of California
  32   32   * All Rights Reserved
  33   33   *
  34   34   * University Acknowledgment- Portions of this document are derived from
  35   35   * software developed by the University of California, Berkeley, and its
  36   36   * contributors.
  37   37   */
↓ open down ↓ 19 lines elided ↑ open up ↑
  57   57   *      nrpos maxcontig mtb]
  58   58   *      13    14        15
  59   59   *
  60   60   *  where specific_options are:
  61   61   *      N - no create
  62   62   *      nsect - The number of sectors per track
  63   63   *      ntrack - The number of tracks per cylinder
  64   64   *      bsize - block size
  65   65   *      fragsize - fragment size
  66   66   *      cgsize - The number of disk cylinders per cylinder group.
  67      - *      free - minimum free space
       67 + *      free - minimum free space
  68   68   *      rps - rotational speed (rev/sec).
  69   69   *      nbpi - number of data bytes per allocated inode
  70   70   *      opt - optimization (space, time)
  71   71   *      apc - number of alternates
  72   72   *      gap - gap size
  73   73   *      nrpos - number of rotational positions
  74   74   *      maxcontig - maximum number of logical blocks that will be
  75   75   *              allocated contiguously before inserting rotational delay
  76   76   *      mtb - if "y", set up file system for eventual growth to over a
  77   77   *              a terabyte
↓ open down ↓ 163 lines elided ↑ open up ↑
 241  241  #define bzero(s, n)     (void) memset(s, 0, n)
 242  242  #define bcmp(s, d, n)   memcmp(s, d, n)
 243  243  
 244  244  #define index(s, r)     strchr(s, r)
 245  245  #define rindex(s, r)    strrchr(s, r)
 246  246  
 247  247  #include        <sys/stat.h>
 248  248  #include        <sys/statvfs.h>
 249  249  #include        <locale.h>
 250  250  #include        <fcntl.h>
 251      -#include        <sys/isa_defs.h>        /* for ENDIAN defines */
      251 +#include        <sys/isa_defs.h>        /* for ENDIAN defines */
 252  252  #include        <sys/vtoc.h>
 253  253  
 254  254  #include        <sys/dkio.h>
 255  255  #include        <sys/asynch.h>
 256  256  
 257  257  extern offset_t llseek();
 258  258  extern char     *getfullblkname();
 259  259  extern long     lrand48();
 260  260  
 261  261  extern int      optind;
↓ open down ↓ 239 lines elided ↑ open up ↑
 501  501  long    rotdelay = -1;                  /* rotational delay between blocks */
 502  502  int     rotdelay_flag = RC_DEFAULT;
 503  503  long    maxcontig;                      /* max contiguous blocks to allocate */
 504  504  int     maxcontig_flag = RC_DEFAULT;
 505  505  long    nsect = DFLNSECT;               /* sectors per track */
 506  506  int     nsect_flag = RC_DEFAULT;
 507  507  long    ntrack = DFLNTRAK;              /* tracks per cylinder group */
 508  508  int     ntrack_flag = RC_DEFAULT;
 509  509  long    bsize = DESBLKSIZE;             /* filesystem block size */
 510  510  int     bsize_flag = RC_DEFAULT;
 511      -long    fragsize = DESFRAGSIZE;         /* filesystem fragment size */
      511 +long    fragsize = DESFRAGSIZE;         /* filesystem fragment size */
 512  512  int     fragsize_flag = RC_DEFAULT;
 513      -long    minfree = MINFREE;              /* fs_minfree */
      513 +long    minfree = MINFREE;              /* fs_minfree */
 514  514  int     minfree_flag = RC_DEFAULT;
 515  515  long    rps = DEFHZ;                    /* revolutions/second of drive */
 516  516  int     rps_flag = RC_DEFAULT;
 517  517  long    nbpi = NBPI;                    /* number of bytes per inode */
 518  518  int     nbpi_flag = RC_DEFAULT;
 519  519  long    nrpos = NRPOS;                  /* number of rotational positions */
 520  520  int     nrpos_flag = RC_DEFAULT;
 521  521  long    apc = 0;                        /* alternate sectors per cylinder */
 522  522  int     apc_flag = RC_DEFAULT;
 523  523  char    opt = 't';                      /* optimization style, `t' or `s' */
↓ open down ↓ 80 lines elided ↑ open up ↑
 604  604  void            alloccsfragfree(void);
 605  605  void            freefrags(daddr32_t, long, long);
 606  606  int             findfreerange(long *, long *);
 607  607  void            resetallocinfo(void);
 608  608  void            extendcg(long);
 609  609  void            ulockfs(void);
 610  610  void            wlockfs(void);
 611  611  void            clockfs(void);
 612  612  void            wtsb(void);
 613  613  static int64_t  checkfragallocated(daddr32_t);
 614      -static struct csum      *read_summaryinfo(struct fs *);
 615      -static diskaddr_t       probe_summaryinfo();
      614 +static struct csum      *read_summaryinfo(struct fs *);
      615 +static diskaddr_t       probe_summaryinfo();
 616  616  
 617  617  int
 618  618  main(int argc, char *argv[])
 619  619  {
 620  620          long i, mincpc, mincpg, ibpcl;
 621  621          long cylno, rpos, blk, j, warn = 0;
 622  622          long mincpgcnt, maxcpg;
 623  623          uint64_t used, bpcg, inospercg;
 624  624          long mapcramped, inodecramped;
 625  625          long postblsize, rotblsize, totalsbsize;
↓ open down ↓ 132 lines elided ↑ open up ↑
 758  758                  case 'b':       /* do nothing for this */
 759  759                          break;
 760  760  
 761  761                  case 'M':       /* grow the mounted file system */
 762  762                          directory = optarg;
 763  763  
 764  764                          /* FALLTHROUGH */
 765  765                  case 'G':       /* grow the file system */
 766  766                          grow = 1;
 767  767                          break;
 768      -                case 'P':       /* probe the file system growing size   */
      768 +                case 'P':       /* probe the file system growing size   */
 769  769                          Pflag = 1;
 770  770                          grow = 1; /* probe mode implies fs growing      */
 771  771                          break;
 772  772                  case 'T':       /* For testing */
 773  773                          testforce = 1;
 774  774  
 775  775                          /* FALLTHROUGH */
 776  776                  case 't':
 777  777                          test = 1;
 778  778                          string = optarg;
↓ open down ↓ 1593 lines elided ↑ open up ↑
2372 2372          }
2373 2373          fsi = fso = -1;
2374 2374  
2375 2375  #ifndef STANDALONE
2376 2376          lockexit(0);
2377 2377  #endif
2378 2378  
2379 2379          return (0);
2380 2380  }
2381 2381  
     2382 +static diskaddr_t
     2383 +get_device_size(int fd)
     2384 +{
     2385 +        struct dk_minfo disk_info;
     2386 +
     2387 +        if ((ioctl(fd, DKIOCGMEDIAINFO, (caddr_t)&disk_info)) == -1)
     2388 +                return (0);
     2389 +
     2390 +        return (disk_info.dki_capacity);
     2391 +}
     2392 +
2382 2393  /*
2383 2394   * Figure out how big the partition we're dealing with is.
2384 2395   * The value returned is in disk blocks (sectors);
2385 2396   */
2386 2397  static diskaddr_t
2387 2398  get_max_size(int fd)
2388 2399  {
2389 2400          struct extvtoc vtoc;
2390 2401          dk_gpt_t *efi_vtoc;
2391 2402          diskaddr_t      slicesize;
↓ open down ↓ 4 lines elided ↑ open up ↑
2396 2407                  label_type = LABEL_TYPE_VTOC;
2397 2408          } else {
2398 2409                  if (index == VT_ENOTSUP || index == VT_ERROR) {
2399 2410                          /* it might be an EFI label */
2400 2411                          index = efi_alloc_and_read(fd, &efi_vtoc);
2401 2412                          label_type = LABEL_TYPE_EFI;
2402 2413                  }
2403 2414          }
2404 2415  
2405 2416          if (index < 0) {
2406      -                switch (index) {
2407      -                case VT_ERROR:
2408      -                        break;
2409      -                case VT_EIO:
2410      -                        errno = EIO;
2411      -                        break;
2412      -                case VT_EINVAL:
2413      -                        errno = EINVAL;
     2417 +                /*
     2418 +                 * Since both attempts to read the label failed, we're
     2419 +                 * going to use DKIOCGMEDIAINFO to get device size.
     2420 +                 */
     2421 +
     2422 +                label_type = LABEL_TYPE_OTHER;
     2423 +                slicesize = get_device_size(fd);
     2424 +                if (slicesize == 0) {
     2425 +                        switch (index) {
     2426 +                        case VT_ERROR:
     2427 +                                break;
     2428 +                        case VT_EIO:
     2429 +                                errno = EIO;
     2430 +                                break;
     2431 +                        case VT_EINVAL:
     2432 +                                errno = EINVAL;
     2433 +                        }
     2434 +                        perror(gettext("Can not determine partition size"));
     2435 +                        lockexit(32);
2414 2436                  }
2415      -                perror(gettext("Can not determine partition size"));
2416      -                lockexit(32);
2417 2437          }
2418 2438  
2419 2439          if (label_type == LABEL_TYPE_EFI) {
2420 2440                  slicesize = efi_vtoc->efi_parts[index].p_size;
2421 2441                  efi_free(efi_vtoc);
2422      -        } else {
     2442 +        } else if (label_type == LABEL_TYPE_VTOC) {
2423 2443                  /*
2424 2444                   * In the vtoc struct, p_size is a 32-bit signed quantity.
2425 2445                   * In the dk_gpt struct (efi's version of the vtoc), p_size
2426 2446                   * is an unsigned 64-bit quantity.  By casting the vtoc's
2427 2447                   * psize to an unsigned 32-bit quantity, it will be copied
2428 2448                   * to 'slicesize' (an unsigned 64-bit diskaddr_t) without
2429 2449                   * sign extension.
2430 2450                   */
2431 2451  
2432 2452                  slicesize = (uint32_t)vtoc.v_part[index].p_size;
↓ open down ↓ 825 lines elided ↑ open up ↑
3258 3278          }
3259 3279  }
3260 3280  
3261 3281  /*
3262 3282   * write a block to the file system -- buffered with aio
3263 3283   */
3264 3284  static void
3265 3285  awtfs(diskaddr_t bno, int size, char *bf, int release)
3266 3286  {
3267 3287          int n;
3268      -        aio_trans       *transp;
3269      -        sigset_t        old_mask;
     3288 +        aio_trans       *transp;
     3289 +        sigset_t        old_mask;
3270 3290  
3271 3291          if (fso == -1)
3272 3292                  return;
3273 3293  
3274 3294          /*
3275 3295           * We need to keep things consistent if we get interrupted,
3276 3296           * so defer any expected interrupts for the time being.
3277 3297           */
3278 3298          block_sigint(&old_mask);
3279 3299  
↓ open down ↓ 1165 lines elided ↑ open up ↑
4445 4465  
4446 4466          /*
4447 4467           * scan all old inodes looking for allocations in the new
4448 4468           * summary info range.  Move the affected frag from the
4449 4469           * generic csfrag list onto the `owned-by-inode' list csfragino.
4450 4470           */
4451 4471          for (i = UFSROOTINO; i < grow_fs_ncg*sblock.fs_ipg && csfrag; ++i) {
4452 4472                  dp = gdinode((ino_t)i);
4453 4473                  switch (dp->di_mode & IFMT) {
4454 4474                          case IFSHAD     :
4455      -                        case IFLNK      :
4456      -                        case IFDIR      :
4457      -                        case IFREG      : break;
     4475 +                        case IFLNK      :
     4476 +                        case IFDIR      :
     4477 +                        case IFREG      : break;
4458 4478                          default         : continue;
4459 4479                  }
4460 4480  
4461 4481                  frags   = dbtofsb(&sblock, dp->di_blocks);
4462 4482  
4463 4483                  checkdirect((ino_t)i, &frags, &dp->di_db[0], NDADDR+NIADDR);
4464 4484                  for (j = 0; j < NIADDR && frags; ++j) {
4465 4485                          /* Negate the block if its an fallocate'd block */
4466 4486                          if (dp->di_ib[j] < 0 && dp->di_ib[j] != UFS_HOLE)
4467 4487                                  checkindirect((ino_t)i, &frags,
↓ open down ↓ 62 lines elided ↑ open up ↑
4530 4550  
4531 4551  /*
4532 4552   * Read the cylinders summary information specified by settings in the
4533 4553   * passed 'fs' structure into a new allocated array of csum structures.
4534 4554   * The caller is responsible for freeing the returned array.
4535 4555   * Return a pointer to an array of csum structures.
4536 4556   */
4537 4557  static struct csum *
4538 4558  read_summaryinfo(struct fs *fsp)
4539 4559  {
4540      -        struct csum     *csp;
     4560 +        struct csum     *csp;
4541 4561          int             i;
4542 4562  
4543 4563          if ((csp = malloc((size_t)fsp->fs_cssize)) == NULL) {
4544 4564                  (void) fprintf(stderr, gettext("cannot create csum list,"
4545 4565                      " not enough memory\n"));
4546 4566                  exit(32);
4547 4567          }
4548 4568  
4549 4569          for (i = 0; i < fsp->fs_cssize; i += fsp->fs_bsize) {
4550 4570                  rdfs(fsbtodb(fsp,
↓ open down ↓ 7 lines elided ↑ open up ↑
4558 4578  
4559 4579  /*
4560 4580   * Check the allocation of fragments that are to be made part of a csum block.
4561 4581   * A fragment is allocated if it is either in the csfragfree list or, it is
4562 4582   * in the csfragino list and has new frags associated with it.
4563 4583   * Return the number of allocated fragments.
4564 4584   */
4565 4585  int64_t
4566 4586  checkfragallocated(daddr32_t frag)
4567 4587  {
4568      -        struct  csfrag  *cfp;
     4588 +        struct  csfrag  *cfp;
4569 4589          /*
4570 4590           * Since the lists are sorted we can break the search if the asked
4571 4591           * frag is smaller then the one in the list.
4572 4592           */
4573 4593          for (cfp = csfragfree; cfp != NULL && frag >= cfp->ofrag;
4574 4594              cfp = cfp->next) {
4575 4595                  if (frag == cfp->ofrag)
4576 4596                          return (1);
4577 4597          }
4578 4598          for (cfp = csfragino; cfp != NULL && frag >= cfp->ofrag;
↓ open down ↓ 15 lines elided ↑ open up ↑
4594 4614   *   block, and use it for additional csum structures.
4595 4615   * Return the maximum size of the new filesystem or 0 if it can't be grown.
4596 4616   * Please note that this function leaves the global list pointers csfrag,
4597 4617   * csfragfree, and csfragino initialized, and the caller is responsible for
4598 4618   * freeing the lists.
4599 4619   */
4600 4620  diskaddr_t
4601 4621  probe_summaryinfo()
4602 4622  {
4603 4623          /* fragments by which the csum block can be extended. */
4604      -        int64_t         growth_csum_frags = 0;
     4624 +        int64_t         growth_csum_frags = 0;
4605 4625          /* fragments by which the filesystem can be extended. */
4606 4626          int64_t         growth_fs_frags = 0;
4607 4627          int64_t         new_fs_cssize;  /* size of csum blk in the new FS */
4608 4628          int64_t         new_fs_ncg;     /* number of cg in the new FS */
4609      -        int64_t         spare_csum;
     4629 +        int64_t         spare_csum;
4610 4630          daddr32_t       oldfrag_daddr;
4611 4631          daddr32_t       newfrag_daddr;
4612 4632          daddr32_t       daddr;
4613 4633          int             i;
4614 4634  
4615 4635          /*
4616 4636           * read and verify the superblock
4617 4637           */
4618 4638          rdfs((diskaddr_t)(SBOFF / sectorsize), (int)sbsize, (char *)&sblock);
4619 4639          (void) checksblock(sblock, 0);
↓ open down ↓ 1063 lines elided ↑ open up ↑
5683 5703  /*
5684 5704   * validate_size
5685 5705   *
5686 5706   * Return 1 if the device appears to be at least "size" sectors long.
5687 5707   * Return 0 if it's shorter or we can't read it.
5688 5708   */
5689 5709  
5690 5710  static int
5691 5711  validate_size(int fd, diskaddr_t size)
5692 5712  {
5693      -        char            buf[DEV_BSIZE];
     5713 +        char    buf[DEV_BSIZE];
5694 5714          int rc;
5695 5715  
5696 5716          if ((llseek(fd, (offset_t)((size - 1) * DEV_BSIZE), SEEK_SET) == -1) ||
5697 5717              (read(fd, buf, DEV_BSIZE)) != DEV_BSIZE)
5698 5718                  rc = 0;
5699 5719          else
5700 5720                  rc = 1;
5701 5721          return (rc);
5702 5722  }
5703 5723  
↓ open down ↓ 135 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX