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>
NEX-14951 teach libdiskmgt about nvme, sata and xen (lint)
NEX-14951 teach libdiskmgt about nvme, sata and xen
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-14023 cfgadm_plugins/shp: memory leak in cfga_get_condition()
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-14022 libdiskmgt: memory leak in slice_get_stats()
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>


 396                 return (ENODEV);
 397             }
 398         } else { /* data_format == FMT_EFI */
 399             if (snum < 0 || snum >= efip->efi_nparts ||
 400                 efip->efi_parts[snum].p_size == 0) {
 401                 efi_free(efip);
 402                 return (ENODEV);
 403             }
 404         }
 405 
 406         /* the slice exists */
 407 
 408         if (nvlist_add_uint32(attrs, DM_INDEX, snum) != 0) {
 409             if (data_format == FMT_EFI) {
 410                 efi_free(efip);
 411             }
 412             return (ENOMEM);
 413         }
 414 
 415         if (data_format == FMT_VTOC) {
 416             if (nvlist_add_uint64(attrs, DM_START, vtoc.v_part[snum].p_start)
 417                 != 0) {
 418                 return (ENOMEM);
 419             }
 420 
 421             if (nvlist_add_uint64(attrs, DM_SIZE, vtoc.v_part[snum].p_size)
 422                 != 0) {
 423                 return (ENOMEM);
 424             }
 425 
 426             if (nvlist_add_uint32(attrs, DM_TAG, vtoc.v_part[snum].p_tag)
 427                 != 0) {
 428                 return (ENOMEM);
 429             }
 430 
 431             if (nvlist_add_uint32(attrs, DM_FLAG, vtoc.v_part[snum].p_flag)
 432                 != 0) {
 433                 return (ENOMEM);
 434             }
 435 
 436         } else { /* data_format == FMT_EFI */
 437             if (nvlist_add_uint64(attrs, DM_START,
 438                 efip->efi_parts[snum].p_start) != 0) {
 439                 efi_free(efip);
 440                 return (ENOMEM);
 441             }
 442 
 443             if (nvlist_add_uint64(attrs, DM_SIZE, efip->efi_parts[snum].p_size)
 444                 != 0) {
 445                 efi_free(efip);
 446                 return (ENOMEM);
 447             }
 448 
 449             if (efip->efi_parts[snum].p_name[0] != 0) {
 450                 char    label[EFI_PART_NAME_LEN + 1];
 451 
 452                 (void) snprintf(label, sizeof (label), "%.*s",
 453                     EFI_PART_NAME_LEN, efip->efi_parts[snum].p_name);
 454                 if (nvlist_add_string(attrs, DM_EFI_NAME, label) != 0) {
 455                     efi_free(efip);
 456                     return (ENOMEM);
 457                 }
 458             }
 459         }
 460 
 461         if (data_format == FMT_EFI) {
 462             efi_free(efip);
 463         }
 464 


 472                 return (ENOMEM);
 473             }
 474         }
 475 
 476         /*
 477          * We need to open the cooked slice (not the raw one) to get the
 478          * correct devid.
 479          */
 480         cooked_fd = open(dp->name, O_RDONLY|O_NDELAY);
 481 
 482         if (cooked_fd >= 0) {
 483             int         no_mem = 0;
 484             ddi_devid_t devid;
 485 
 486             if (devid_get(cooked_fd, &devid) == 0) {
 487                 char    *minor;
 488 
 489                 if (devid_get_minor_name(cooked_fd, &minor) == 0) {
 490                     char        *devidstr;
 491 
 492                     if ((devidstr = devid_str_encode(devid, minor)) != 0) {

 493 
 494                         if (nvlist_add_string(attrs, DM_DEVICEID, devidstr)
 495                             != 0) {
 496                             no_mem = 1;
 497                         }
 498 
 499                         devid_str_free(devidstr);
 500                     }
 501                     devid_str_free(minor);
 502                 }
 503                 devid_free(devid);
 504             }
 505             (void) close(cooked_fd);
 506 
 507             if (no_mem) {
 508                 return (ENOMEM);
 509             }
 510         }
 511 
 512         return (0);
 513 }
 514 
 515 static descriptor_t **


 526         slice_t         *devp;
 527         descriptor_t    **slices;
 528 
 529         if ((fd = drive_open_disk(desc->p.disk, NULL, 0)) < 0) {
 530             *errp = ENODEV;
 531             return (NULL);
 532         }
 533 
 534         if ((status = read_extvtoc(fd, &vtoc)) >= 0) {
 535             data_format = FMT_VTOC;
 536         } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) {
 537             data_format = FMT_EFI;
 538         } else {
 539             (void) close(fd);
 540             *errp = 0;
 541             return (libdiskmgt_empty_desc_array(errp));
 542         }
 543         (void) close(fd);
 544 
 545         /* count the number of slices */
 546         for (cnt = 0, devp = desc->p.disk->aliases->devpaths; devp != NULL;
 547             devp = devp->next, cnt++);

 548 
 549         /* allocate the array for the descriptors */
 550         slices = (descriptor_t **)calloc(cnt + 1, sizeof (descriptor_t *));
 551         if (slices == NULL) {
 552             if (data_format == FMT_EFI) {
 553                 efi_free(efip);
 554             }
 555             *errp = ENOMEM;
 556             return (NULL);
 557         }
 558 
 559         /* get the media name from the descriptor */
 560         if (desc->type == DM_MEDIA) {
 561             media_name = desc->name;
 562         } else {
 563             /* must be a DM_PARTITION */
 564             media_name = desc->secondary_name;
 565         }
 566 
 567         pos = 0;


 753 
 754         /*
 755          * If we found a match on the name we now have to check that this
 756          * slice really exists (non-0 size).
 757          */
 758 
 759         slice_num = get_slice_num(dp);
 760         /* can't get slicenum, so no slice */
 761         if (slice_num == -1) {
 762             *errp = ENODEV;
 763             return (1);
 764         }
 765 
 766         if ((fd = drive_open_disk(diskp, NULL, 0)) < 0) {
 767             *errp = ENODEV;
 768             return (1);
 769         }
 770 
 771         if ((status = read_extvtoc(fd, &vtoc)) >= 0) {
 772             data_format = FMT_VTOC;
 773         } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) {


 774             data_format = FMT_EFI;




 775         } else {
 776             (void) close(fd);
 777             *errp = ENODEV;
 778             return (1);
 779         }
 780         (void) close(fd);
 781 
 782         if (data_format == FMT_VTOC) {
 783             if (slice_num < vtoc.v_nparts &&
 784                 vtoc.v_part[slice_num].p_size > 0) {
 785                 *errp = 0;
 786                 return (1);
 787             }
 788         } else { /* data_format == FMT_EFI */
 789             if (slice_num < efip->efi_nparts &&
 790                 efip->efi_parts[slice_num].p_size > 0) {
 791                 efi_free(efip);
 792                 *errp = 0;
 793                 return (1);
 794             }


 396                         return (ENODEV);
 397                 }
 398         } else { /* data_format == FMT_EFI */
 399                 if (snum < 0 || snum >= efip->efi_nparts ||
 400                     efip->efi_parts[snum].p_size == 0) {
 401                         efi_free(efip);
 402                         return (ENODEV);
 403                 }
 404         }
 405 
 406         /* the slice exists */
 407 
 408         if (nvlist_add_uint32(attrs, DM_INDEX, snum) != 0) {
 409                 if (data_format == FMT_EFI) {
 410                         efi_free(efip);
 411                 }
 412                 return (ENOMEM);
 413         }
 414 
 415         if (data_format == FMT_VTOC) {
 416                 if (nvlist_add_uint64(attrs, DM_START,
 417                     vtoc.v_part[snum].p_start) != 0) {
 418                         return (ENOMEM);
 419                 }
 420 
 421                 if (nvlist_add_uint64(attrs, DM_SIZE,
 422                     vtoc.v_part[snum].p_size) != 0) {
 423                         return (ENOMEM);
 424                 }
 425 
 426                 if (nvlist_add_uint32(attrs, DM_TAG,
 427                     vtoc.v_part[snum].p_tag) != 0) {
 428                         return (ENOMEM);
 429                 }
 430 
 431                 if (nvlist_add_uint32(attrs, DM_FLAG,
 432                     vtoc.v_part[snum].p_flag) != 0) {
 433                         return (ENOMEM);
 434                 }

 435         } else { /* data_format == FMT_EFI */
 436                 if (nvlist_add_uint64(attrs, DM_START,
 437                     efip->efi_parts[snum].p_start) != 0) {
 438                         efi_free(efip);
 439                         return (ENOMEM);
 440                 }
 441 
 442                 if (nvlist_add_uint64(attrs, DM_SIZE,
 443                     efip->efi_parts[snum].p_size) != 0) {
 444                         efi_free(efip);
 445                         return (ENOMEM);
 446                 }
 447 
 448                 if (efip->efi_parts[snum].p_name[0] != 0) {
 449                         char    label[EFI_PART_NAME_LEN + 1];
 450 
 451                         (void) snprintf(label, sizeof (label), "%.*s",
 452                             EFI_PART_NAME_LEN, efip->efi_parts[snum].p_name);
 453                         if (nvlist_add_string(attrs, DM_EFI_NAME, label) != 0) {
 454                                 efi_free(efip);
 455                                 return (ENOMEM);
 456                         }
 457                 }
 458         }
 459 
 460         if (data_format == FMT_EFI) {
 461                 efi_free(efip);
 462         }
 463 


 471                         return (ENOMEM);
 472                 }
 473         }
 474 
 475         /*
 476          * We need to open the cooked slice (not the raw one) to get the
 477          * correct devid.
 478          */
 479         cooked_fd = open(dp->name, O_RDONLY|O_NDELAY);
 480 
 481         if (cooked_fd >= 0) {
 482                 int             no_mem = 0;
 483                 ddi_devid_t     devid;
 484 
 485                 if (devid_get(cooked_fd, &devid) == 0) {
 486                         char    *minor;
 487 
 488                         if (devid_get_minor_name(cooked_fd, &minor) == 0) {
 489                                 char    *devidstr;
 490 
 491                                 devidstr = devid_str_encode(devid, minor);
 492                                 if (devidstr != NULL) {
 493 
 494                                         if (nvlist_add_string(attrs,
 495                                             DM_DEVICEID, devidstr) != 0) {
 496                                                 no_mem = 1;
 497                                         }
 498 
 499                                         devid_str_free(devidstr);
 500                                 }
 501                                 devid_str_free(minor);
 502                         }
 503                         devid_free(devid);
 504                 }
 505                 (void) close(cooked_fd);
 506 
 507                 if (no_mem) {
 508                         return (ENOMEM);
 509                 }
 510         }
 511 
 512         return (0);
 513 }
 514 
 515 static descriptor_t **


 526         slice_t         *devp;
 527         descriptor_t    **slices;
 528 
 529         if ((fd = drive_open_disk(desc->p.disk, NULL, 0)) < 0) {
 530                 *errp = ENODEV;
 531                 return (NULL);
 532         }
 533 
 534         if ((status = read_extvtoc(fd, &vtoc)) >= 0) {
 535                 data_format = FMT_VTOC;
 536         } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) {
 537                 data_format = FMT_EFI;
 538         } else {
 539                 (void) close(fd);
 540                 *errp = 0;
 541                 return (libdiskmgt_empty_desc_array(errp));
 542         }
 543         (void) close(fd);
 544 
 545         /* count the number of slices */
 546         devp = desc->p.disk->aliases->devpaths;
 547         for (cnt = 0; devp != NULL; devp = devp->next)
 548                 cnt++;
 549 
 550         /* allocate the array for the descriptors */
 551         slices = (descriptor_t **)calloc(cnt + 1, sizeof (descriptor_t *));
 552         if (slices == NULL) {
 553                 if (data_format == FMT_EFI) {
 554                         efi_free(efip);
 555                 }
 556                 *errp = ENOMEM;
 557                 return (NULL);
 558         }
 559 
 560         /* get the media name from the descriptor */
 561         if (desc->type == DM_MEDIA) {
 562                 media_name = desc->name;
 563         } else {
 564                 /* must be a DM_PARTITION */
 565                 media_name = desc->secondary_name;
 566         }
 567 
 568         pos = 0;


 754 
 755         /*
 756          * If we found a match on the name we now have to check that this
 757          * slice really exists (non-0 size).
 758          */
 759 
 760         slice_num = get_slice_num(dp);
 761         /* can't get slicenum, so no slice */
 762         if (slice_num == -1) {
 763                 *errp = ENODEV;
 764                 return (1);
 765         }
 766 
 767         if ((fd = drive_open_disk(diskp, NULL, 0)) < 0) {
 768                 *errp = ENODEV;
 769                 return (1);
 770         }
 771 
 772         if ((status = read_extvtoc(fd, &vtoc)) >= 0) {
 773                 data_format = FMT_VTOC;
 774         } else if (status == VT_ENOTSUP) {
 775                 status = efi_alloc_and_read(fd, &efip);
 776                 if (status >= 0) {
 777                         data_format = FMT_EFI;
 778                 } else if (status == VT_ERROR && errno == ENOTTY) {
 779                         *errp = 0;
 780                         return (1);
 781                 }
 782         } else {
 783                 (void) close(fd);
 784                 *errp = ENODEV;
 785                 return (1);
 786         }
 787         (void) close(fd);
 788 
 789         if (data_format == FMT_VTOC) {
 790                 if (slice_num < vtoc.v_nparts &&
 791                     vtoc.v_part[slice_num].p_size > 0) {
 792                         *errp = 0;
 793                         return (1);
 794                 }
 795         } else { /* data_format == FMT_EFI */
 796                 if (slice_num < efip->efi_nparts &&
 797                     efip->efi_parts[slice_num].p_size > 0) {
 798                         efi_free(efip);
 799                         *errp = 0;
 800                         return (1);
 801                 }