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>
48 #include <sys/stat.h> 49 #include <netinet/in.h> 50 #include <netinet/udp.h> 51 #include <netinet/in_systm.h> 52 #include <arpa/tftp.h> 53 54 #include <string.h> 55 56 #include "stand.h" 57 #include "net.h" 58 #include "netif.h" 59 60 #include "tftp.h" 61 62 struct tftp_handle; 63 64 static int tftp_open(const char *path, struct open_file *f); 65 static int tftp_close(struct open_file *f); 66 static int tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len); 67 static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid); 68 static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid); 69 static off_t tftp_seek(struct open_file *f, off_t offset, int where); 70 static int tftp_set_blksize(struct tftp_handle *h, const char *str); 71 static int tftp_stat(struct open_file *f, struct stat *sb); 72 static ssize_t sendrecv_tftp(struct tftp_handle *h, 73 ssize_t (*sproc)(struct iodesc *, void *, size_t), 74 void *sbuf, size_t ssize, 75 ssize_t (*rproc)(struct tftp_handle *h, void **, void **, time_t, unsigned short *), 76 void **, void **, unsigned short *rtype); 77 78 struct fs_ops tftp_fsops = { 79 "tftp", 80 tftp_open, 81 tftp_close, 82 tftp_read, 83 tftp_write, 84 tftp_seek, 85 tftp_stat, 86 null_readdir 87 }; 88 89 extern struct in_addr servip; 90 91 static int tftpport = 2000; 92 static int is_open = 0; 93 94 /* 95 * The legacy TFTP_BLKSIZE value was SEGSIZE(512). 96 * TFTP_REQUESTED_BLKSIZE of 1428 is (Ethernet MTU, less the TFTP, UDP and 97 * IP header lengths). 98 */ 99 #define TFTP_REQUESTED_BLKSIZE 1428 100 101 /* 102 * Choose a blksize big enough so we can test with Ethernet 103 * Jumbo frames in the future. 
 546         return (0);
 547 }
 548 
 549 static int 
 550 tftp_close(struct open_file *f)
 551 {
 552         struct tftp_handle *tftpfile;
 553         tftpfile = (struct tftp_handle *) f->f_fsdata;
 554 
 555         /* let it time out ... */
 556 
 557         if (tftpfile) {
 558                 free(tftpfile->path);
 559                 free(tftpfile->pkt);
 560                 free(tftpfile);
 561         }
 562         is_open = 0;
 563         return (0);
 564 }
 565 
 566 static int
 567 tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused,
 568     size_t *resid __unused /* out */)
 569 {
 570         return (EROFS);
 571 }
 572 
 573 static int 
 574 tftp_stat(struct open_file *f, struct stat *sb)
 575 {
 576         struct tftp_handle *tftpfile;
 577         tftpfile = (struct tftp_handle *) f->f_fsdata;
 578 
 579         sb->st_mode = 0444 | S_IFREG;
 580         sb->st_nlink = 1;
 581         sb->st_uid = 0;
 582         sb->st_gid = 0;
 583         sb->st_size = (off_t) tftpfile->tftp_tsize;
 584         return (0);
 585 }
 586 
 587 static off_t
 588 tftp_seek(struct open_file *f, off_t offset, int where)
 589 {
 590         struct tftp_handle *tftpfile;
 591         tftpfile = (struct tftp_handle *) f->f_fsdata;
 592 
 | 
  48 #include <sys/stat.h>
  49 #include <netinet/in.h>
  50 #include <netinet/udp.h>
  51 #include <netinet/in_systm.h>
  52 #include <arpa/tftp.h>
  53 
  54 #include <string.h>
  55 
  56 #include "stand.h"
  57 #include "net.h"
  58 #include "netif.h"
  59 
  60 #include "tftp.h"
  61 
  62 struct tftp_handle;
  63 
  64 static int      tftp_open(const char *path, struct open_file *f);
  65 static int      tftp_close(struct open_file *f);
  66 static int      tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
  67 static int      tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
  68 static off_t    tftp_seek(struct open_file *f, off_t offset, int where);
  69 static int      tftp_set_blksize(struct tftp_handle *h, const char *str);
  70 static int      tftp_stat(struct open_file *f, struct stat *sb);
  71 static ssize_t sendrecv_tftp(struct tftp_handle *h,
  72     ssize_t (*sproc)(struct iodesc *, void *, size_t),
  73     void *sbuf, size_t ssize,
  74     ssize_t (*rproc)(struct tftp_handle *h, void **, void **, time_t, unsigned short *),
  75     void **, void **, unsigned short *rtype);
  76 
  77 struct fs_ops tftp_fsops = {
  78         "tftp",
  79         tftp_open,
  80         tftp_close,
  81         tftp_read,
  82         null_write,
  83         tftp_seek,
  84         tftp_stat,
  85         null_readdir
  86 };
  87 
  88 extern struct in_addr servip;
  89 
  90 static int      tftpport = 2000;
  91 static int      is_open = 0;
  92 
  93 /*
  94  * The legacy TFTP_BLKSIZE value was SEGSIZE(512).
  95  * TFTP_REQUESTED_BLKSIZE of 1428 is (Ethernet MTU, less the TFTP, UDP and
  96  * IP header lengths).
  97  */
  98 #define TFTP_REQUESTED_BLKSIZE 1428
  99 
 100 /*
 101  * Choose a blksize big enough so we can test with Ethernet
 102  * Jumbo frames in the future.
 545         return (0);
 546 }
 547 
 548 static int 
 549 tftp_close(struct open_file *f)
 550 {
 551         struct tftp_handle *tftpfile;
 552         tftpfile = (struct tftp_handle *) f->f_fsdata;
 553 
 554         /* let it time out ... */
 555 
 556         if (tftpfile) {
 557                 free(tftpfile->path);
 558                 free(tftpfile->pkt);
 559                 free(tftpfile);
 560         }
 561         is_open = 0;
 562         return (0);
 563 }
 564 
 565 static int 
 566 tftp_stat(struct open_file *f, struct stat *sb)
 567 {
 568         struct tftp_handle *tftpfile;
 569         tftpfile = (struct tftp_handle *) f->f_fsdata;
 570 
 571         sb->st_mode = 0444 | S_IFREG;
 572         sb->st_nlink = 1;
 573         sb->st_uid = 0;
 574         sb->st_gid = 0;
 575         sb->st_size = (off_t) tftpfile->tftp_tsize;
 576         return (0);
 577 }
 578 
 579 static off_t
 580 tftp_seek(struct open_file *f, off_t offset, int where)
 581 {
 582         struct tftp_handle *tftpfile;
 583         tftpfile = (struct tftp_handle *) f->f_fsdata;
 584 
 |