1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2013 Joyent, Inc.  All rights reserved.
  14  * Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  15  */
  16 
  17 
  18 #ifndef _SYS_BOOTCONF_H
  19 #define _SYS_BOOTCONF_H
  20 
  21 /*
  22  * Boot time configuration information objects
  23  */
  24 
  25 #include <sys/types.h>
  26 #include <sys/memlist.h>
  27 #include <sys/ccompile.h>
  28 #include <net/if.h>                       /* for IFNAMSIZ */
  29 
  30 #ifdef __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 /*
  35  * Masks for bsys_alloc memory allocator. These overlap with the ones for intel
  36  * and sun because they're used by the common kernel.
  37  */
  38 #define BO_NO_ALIGN     0x00001000
  39 #define BO_ALIGN_DONTCARE       -1
  40 
  41 struct bsys_mem {
  42         struct memlist  physinstalled;
  43 };
  44 
  45 #define BO_VERSION      1       /* bootops interface revision */
  46 
  47 typedef struct bootops {
  48         uint_t  bsys_version;
  49         struct bsys_mem boot_mem;
  50         caddr_t (*bsys_alloc)(struct bootops *, caddr_t, size_t, int);
  51         void    (*bsys_free)(struct bootops *, caddr_t, size_t);
  52         int     (*bsys_getproplen)(struct bootops *, const char *);
  53         int     (*bsys_getprop)(struct bootops *, const char *, void *);
  54         void    (*bsys_printf)(struct bootops *, const char *, ...);
  55 } bootops_t;
  56 
  57 #define BOP_GETVERSION(bop)             ((bop)->bsys_version)
  58 #define BOP_ALLOC(bop, virthint, size, align)   \
  59                 ((bop)->bsys_alloc)(bop, virthint, size, align)
  60 #define BOP_FREE(bop, virt, size)       ((bop)->bsys_free)(bop, virt, size)
  61 #define BOP_GETPROPLEN(bop, name)       ((bop)->bsys_getproplen)(bop, name)
  62 #define BOP_GETPROP(bop, name, buf)     ((bop)->bsys_getprop)(bop, name, buf)
  63 #define BOP_PUTSARG(bop, msg, arg)      ((bop)->bsys_printf)(bop, msg, arg)
  64 
  65 /*
  66  * Boot configuration information
  67  */
  68 
  69 #define BO_MAXFSNAME    16
  70 #define BO_MAXOBJNAME   256
  71 
  72 struct bootobj {
  73         char    bo_fstype[BO_MAXFSNAME];        /* vfs type name (e.g. nfs) */
  74         char    bo_name[BO_MAXOBJNAME];         /* name of object */
  75         int     bo_flags;                       /* flags, see below */
  76         int     bo_size;                        /* number of blocks */
  77         struct vnode *bo_vp;                    /* vnode of object */
  78         char    bo_devname[BO_MAXOBJNAME];
  79         char    bo_ifname[BO_MAXOBJNAME];
  80         int     bo_ppa;
  81 };
  82 
  83 /*
  84  * flags
  85  */
  86 #define BO_VALID        0x01    /* all information in object is valid */
  87 #define BO_BUSY         0x02    /* object is busy */
  88 
  89 extern struct bootobj rootfs;
  90 extern struct bootobj swapfile;
  91 
  92 extern char *default_path;
  93 extern int modrootloaded;
  94 extern char kern_bootargs[];
  95 extern char kern_bootfile[];
  96 
  97 extern int strplumb(void);
  98 extern char *strplumb_get_netdev_path(void);
  99 extern void consconfig(void);
 100 extern void release_bootstrap(void);
 101 
 102 extern void bop_panic(const char *);
 103 extern void boot_prop_finish(void);
 104 extern void bop_printf(struct bootops *, const char *, ...);
 105 
 106 extern struct bootops *bootops;
 107 extern int netboot;
 108 extern char *dhcack;
 109 extern int dhcacklen;
 110 extern char dhcifname[IFNAMSIZ];
 111 
 112 extern char *netdev_path;
 113 
 114 #ifdef __cplusplus
 115 }
 116 #endif
 117 
 118 #endif /* _SYS_BOOTCONF_H */