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>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
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
    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>


  15  *    documentation and/or other materials provided with the distribution.
  16  * 3. All advertising materials mentioning features or use of this software
  17  *    must display the following acknowledgement:
  18  *      This product includes software developed by TooLs GmbH.
  19  * 4. The name of TooLs GmbH may not be used to endorse or promote products
  20  *    derived from this software without specific prior written permission.
  21  *
  22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
  23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  31  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 #include <sys/cdefs.h>
  35 __FBSDID("$FreeBSD$");
  36 
  37 /*
  38  * Stand-alone ISO9660 file reading package.
  39  *
  40  * Note: This doesn't support Rock Ridge extensions, extended attributes,
  41  * blocksizes other than 2048 bytes, multi-extent files, etc.
  42  */
  43 #include <sys/param.h>
  44 #include <string.h>
  45 #include <sys/dirent.h>
  46 #include <isofs/cd9660/iso.h>
  47 #include <isofs/cd9660/cd9660_rrip.h>
  48 
  49 #include "stand.h"
  50 
  51 #define SUSP_CONTINUATION       "CE"
  52 #define SUSP_PRESENT            "SP"
  53 #define SUSP_STOP               "ST"
  54 #define SUSP_EXTREF             "ER"
  55 #define RRIP_NAME               "NM"
  56 
  57 typedef struct {
  58         ISO_SUSP_HEADER         h;
  59         u_char signature        [ISODCL (  5,    6)];
  60         u_char len_skp          [ISODCL (  7,    7)]; /* 711 */
  61 } ISO_SUSP_PRESENT;
  62         
  63 static int      buf_read_file(struct open_file *f, char **buf_p,
  64                     size_t *size_p);
  65 static int      cd9660_open(const char *path, struct open_file *f);
  66 static int      cd9660_close(struct open_file *f);
  67 static int      cd9660_read(struct open_file *f, void *buf, size_t size,
  68                     size_t *resid);
  69 static int      cd9660_write(struct open_file *f, void *buf, size_t size,
  70                     size_t *resid);
  71 static off_t    cd9660_seek(struct open_file *f, off_t offset, int where);
  72 static int      cd9660_stat(struct open_file *f, struct stat *sb);
  73 static int      cd9660_readdir(struct open_file *f, struct dirent *d);
  74 static int      dirmatch(struct open_file *f, const char *path,
  75                     struct iso_directory_record *dp, int use_rrip, int lenskip);
  76 static int      rrip_check(struct open_file *f, struct iso_directory_record *dp,
  77                     int *lenskip);
  78 static char     *rrip_lookup_name(struct open_file *f,
  79                     struct iso_directory_record *dp, int lenskip, size_t *len);
  80 static ISO_SUSP_HEADER *susp_lookup_record(struct open_file *f,
  81                     const char *identifier, struct iso_directory_record *dp,
  82                     int lenskip);
  83 
  84 struct fs_ops cd9660_fsops = {
  85         "cd9660",
  86         cd9660_open,
  87         cd9660_close,
  88         cd9660_read,
  89         cd9660_write,
  90         cd9660_seek,
  91         cd9660_stat,
  92         cd9660_readdir
  93 };
  94 
  95 #define F_ISDIR         0x0001          /* Directory */
  96 #define F_ROOTDIR       0x0002          /* Root directory */
  97 #define F_RR            0x0004          /* Rock Ridge on this volume */
  98 
  99 struct file {
 100         int             f_flags;        /* file flags */
 101         off_t           f_off;          /* Current offset within file */
 102         daddr_t         f_bno;          /* Starting block number */
 103         off_t           f_size;         /* Size of file */
 104         daddr_t         f_buf_blkno;    /* block number of data block */        
 105         char            *f_buf;         /* buffer for data block */
 106         int             f_susp_skip;    /* len_skip for SUSP records */
 107 };
 108 
 109 struct ptable_ent {


 539                 }
 540         }
 541         reclen = sizeof(struct dirent) - (MAXNAMLEN+1) + namelen + 1;
 542         reclen = (reclen + 3) & ~3;
 543 
 544         d->d_fileno = isonum_733(ep->extent);
 545         d->d_reclen = reclen;
 546         if (isonum_711(ep->flags) & 2)
 547                 d->d_type = DT_DIR;
 548         else
 549                 d->d_type = DT_REG;
 550         d->d_namlen = namelen;
 551 
 552         bcopy(name, d->d_name, d->d_namlen);
 553         d->d_name[d->d_namlen] = 0;
 554 
 555         fp->f_off += isonum_711(ep->length);
 556         return (0);
 557 }
 558 
 559 static int
 560 cd9660_write(struct open_file *f __unused, void *start __unused, size_t size __unused, size_t *resid __unused)
 561 {
 562         return EROFS;
 563 }
 564 
 565 static off_t
 566 cd9660_seek(struct open_file *f, off_t offset, int where)
 567 {
 568         struct file *fp = (struct file *)f->f_fsdata;
 569 
 570         switch (where) {
 571         case SEEK_SET:
 572                 fp->f_off = offset;
 573                 break;
 574         case SEEK_CUR:
 575                 fp->f_off += offset;
 576                 break;
 577         case SEEK_END:
 578                 fp->f_off = fp->f_size - offset;
 579                 break;
 580         default:
 581                 return -1;
 582         }
 583         return fp->f_off;
 584 }


  15  *    documentation and/or other materials provided with the distribution.
  16  * 3. All advertising materials mentioning features or use of this software
  17  *    must display the following acknowledgement:
  18  *      This product includes software developed by TooLs GmbH.
  19  * 4. The name of TooLs GmbH may not be used to endorse or promote products
  20  *    derived from this software without specific prior written permission.
  21  *
  22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
  23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  31  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 #include <sys/cdefs.h>

  35 
  36 /*
  37  * Stand-alone ISO9660 file reading package.
  38  *
  39  * Note: This doesn't support Rock Ridge extensions, extended attributes,
  40  * blocksizes other than 2048 bytes, multi-extent files, etc.
  41  */
  42 #include <sys/param.h>
  43 #include <string.h>
  44 #include <sys/dirent.h>
  45 #include <isofs/cd9660/iso.h>
  46 #include <isofs/cd9660/cd9660_rrip.h>
  47 
  48 #include "stand.h"
  49 
  50 #define SUSP_CONTINUATION       "CE"
  51 #define SUSP_PRESENT            "SP"
  52 #define SUSP_STOP               "ST"
  53 #define SUSP_EXTREF             "ER"
  54 #define RRIP_NAME               "NM"
  55 
  56 typedef struct {
  57         ISO_SUSP_HEADER         h;
  58         u_char signature        [ISODCL (  5,    6)];
  59         u_char len_skp          [ISODCL (  7,    7)]; /* 711 */
  60 } ISO_SUSP_PRESENT;
  61         
  62 static int      buf_read_file(struct open_file *f, char **buf_p,
  63                     size_t *size_p);
  64 static int      cd9660_open(const char *path, struct open_file *f);
  65 static int      cd9660_close(struct open_file *f);
  66 static int      cd9660_read(struct open_file *f, void *buf, size_t size,
  67                     size_t *resid);


  68 static off_t    cd9660_seek(struct open_file *f, off_t offset, int where);
  69 static int      cd9660_stat(struct open_file *f, struct stat *sb);
  70 static int      cd9660_readdir(struct open_file *f, struct dirent *d);
  71 static int      dirmatch(struct open_file *f, const char *path,
  72                     struct iso_directory_record *dp, int use_rrip, int lenskip);
  73 static int      rrip_check(struct open_file *f, struct iso_directory_record *dp,
  74                     int *lenskip);
  75 static char     *rrip_lookup_name(struct open_file *f,
  76                     struct iso_directory_record *dp, int lenskip, size_t *len);
  77 static ISO_SUSP_HEADER *susp_lookup_record(struct open_file *f,
  78                     const char *identifier, struct iso_directory_record *dp,
  79                     int lenskip);
  80 
  81 struct fs_ops cd9660_fsops = {
  82         "cd9660",
  83         cd9660_open,
  84         cd9660_close,
  85         cd9660_read,
  86         null_write,
  87         cd9660_seek,
  88         cd9660_stat,
  89         cd9660_readdir
  90 };
  91 
  92 #define F_ISDIR         0x0001          /* Directory */
  93 #define F_ROOTDIR       0x0002          /* Root directory */
  94 #define F_RR            0x0004          /* Rock Ridge on this volume */
  95 
  96 struct file {
  97         int             f_flags;        /* file flags */
  98         off_t           f_off;          /* Current offset within file */
  99         daddr_t         f_bno;          /* Starting block number */
 100         off_t           f_size;         /* Size of file */
 101         daddr_t         f_buf_blkno;    /* block number of data block */        
 102         char            *f_buf;         /* buffer for data block */
 103         int             f_susp_skip;    /* len_skip for SUSP records */
 104 };
 105 
 106 struct ptable_ent {


 536                 }
 537         }
 538         reclen = sizeof(struct dirent) - (MAXNAMLEN+1) + namelen + 1;
 539         reclen = (reclen + 3) & ~3;
 540 
 541         d->d_fileno = isonum_733(ep->extent);
 542         d->d_reclen = reclen;
 543         if (isonum_711(ep->flags) & 2)
 544                 d->d_type = DT_DIR;
 545         else
 546                 d->d_type = DT_REG;
 547         d->d_namlen = namelen;
 548 
 549         bcopy(name, d->d_name, d->d_namlen);
 550         d->d_name[d->d_namlen] = 0;
 551 
 552         fp->f_off += isonum_711(ep->length);
 553         return (0);
 554 }
 555 






 556 static off_t
 557 cd9660_seek(struct open_file *f, off_t offset, int where)
 558 {
 559         struct file *fp = (struct file *)f->f_fsdata;
 560 
 561         switch (where) {
 562         case SEEK_SET:
 563                 fp->f_off = offset;
 564                 break;
 565         case SEEK_CUR:
 566                 fp->f_off += offset;
 567                 break;
 568         case SEEK_END:
 569                 fp->f_off = fp->f_size - offset;
 570                 break;
 571         default:
 572                 return -1;
 573         }
 574         return fp->f_off;
 575 }