aboutsummaryrefslogtreecommitdiff
path: root/stand/common
diff options
context:
space:
mode:
Diffstat (limited to 'stand/common')
-rw-r--r--stand/common/dev_net.c41
-rw-r--r--stand/common/gfx_fb.c63
-rw-r--r--stand/common/gfx_fb.h1
-rw-r--r--stand/common/misc.c13
-rw-r--r--stand/common/modinfo.c2
5 files changed, 108 insertions, 12 deletions
diff --git a/stand/common/dev_net.c b/stand/common/dev_net.c
index 964fa514cac5..d1c48d40691a 100644
--- a/stand/common/dev_net.c
+++ b/stand/common/dev_net.c
@@ -66,6 +66,10 @@
#include "dev_net.h"
#include "bootstrap.h"
+#ifndef NETPROTO_DEFAULT
+# define NETPROTO_DEFAULT NET_NFS
+#endif
+
static char *netdev_name;
static int netdev_sock = -1;
static int netdev_opens;
@@ -182,6 +186,7 @@ net_open(struct open_file *f, ...)
setenv("boot.netif.mtu", mtu, 1);
}
+ DEBUG_PRINTF(1,("%s: netproto=%d\n", __func__, netproto));
}
netdev_opens++;
dev->d_opendata = &netdev_sock;
@@ -193,7 +198,7 @@ net_close(struct open_file *f)
{
struct devdesc *dev;
- DEBUG_PRINTF(1,("%s: opens=%d\n", __func__, netdev_opens));
+ DEBUG_PRINTF(2,("%s: opens=%d\n", __func__, netdev_opens));
dev = f->f_devdata;
dev->d_opendata = NULL;
@@ -303,7 +308,7 @@ net_getparams(int sock)
return (EIO);
}
exit:
- if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
+ if ((rootaddr = net_parse_rootpath()) != htonl(INADDR_NONE))
rootip.s_addr = rootaddr;
DEBUG_PRINTF(1,("%s: proto: %d\n", __func__, netproto));
@@ -344,11 +349,17 @@ net_print(int verbose)
return (ret);
}
+bool
+is_tftp(void)
+{
+ return (netproto == NET_TFTP);
+}
+
/*
* Parses the rootpath if present
*
* The rootpath format can be in the form
- * <scheme>://ip/path
+ * <scheme>://ip[:port]/path
* <scheme>:/path
*
* For compatibility with previous behaviour it also accepts as an NFS scheme
@@ -363,10 +374,10 @@ net_print(int verbose)
uint32_t
net_parse_rootpath(void)
{
- n_long addr = htonl(INADDR_NONE);
+ n_long addr = 0;
size_t i;
char ip[FNAME_SIZE];
- char *ptr, *val;
+ char *ptr, *portp, *val;
netproto = NET_NONE;
@@ -381,7 +392,7 @@ net_parse_rootpath(void)
ptr = rootpath;
/* Fallback for compatibility mode */
if (netproto == NET_NONE) {
- netproto = NET_NFS;
+ netproto = NETPROTO_DEFAULT;
(void)strsep(&ptr, ":");
if (ptr != NULL) {
addr = inet_addr(rootpath);
@@ -394,16 +405,21 @@ net_parse_rootpath(void)
if (*ptr == '/') {
/* we are in the form <scheme>://, we do expect an ip */
ptr++;
- /*
- * XXX when http will be there we will need to check for
- * a port, but right now we do not need it yet
- */
+ portp = val = strchr(ptr, ':');
+ if (val != NULL) {
+ val++;
+ rootport = strtol(val, NULL, 10);
+ }
val = strchr(ptr, '/');
if (val != NULL) {
+ if (portp == NULL)
+ portp = val;
snprintf(ip, sizeof(ip), "%.*s",
- (int)((uintptr_t)val - (uintptr_t)ptr),
+ (int)(portp - ptr),
ptr);
addr = inet_addr(ip);
+ DEBUG_PRINTF(1,("ip=%s addr=%#x\n",
+ ip, addr));
bcopy(val, rootpath, strlen(val) + 1);
}
} else {
@@ -411,6 +427,7 @@ net_parse_rootpath(void)
bcopy(ptr, rootpath, strlen(ptr) + 1);
}
}
-
+ if (addr == 0)
+ addr = htonl(INADDR_NONE);
return (addr);
}
diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c
index af72ab1a4c99..659bf8540422 100644
--- a/stand/common/gfx_fb.c
+++ b/stand/common/gfx_fb.c
@@ -232,6 +232,69 @@ gfx_parse_mode_str(char *str, int *x, int *y, int *depth)
return (true);
}
+/*
+ * Returns true if we set the color from pre-existing environment, false if
+ * just used existing defaults.
+ */
+static bool
+gfx_fb_evalcolor(const char *envname, teken_color_t *cattr,
+ ev_sethook_t sethook, ev_unsethook_t unsethook)
+{
+ const char *ptr;
+ char env[10];
+ int eflags = EV_VOLATILE | EV_NOKENV;
+ bool from_env = false;
+
+ ptr = getenv(envname);
+ if (ptr != NULL) {
+ *cattr = strtol(ptr, NULL, 10);
+
+ /*
+ * If we can't unset the value, then it's probably hooked
+ * properly and we can just carry on. Otherwise, we want to
+ * reinitialize it so that we can hook it for the console that
+ * we're resetting defaults for.
+ */
+ if (unsetenv(envname) != 0)
+ return (true);
+ from_env = true;
+
+ /*
+ * If we're carrying over an existing value, we *do* want that
+ * to propagate to the kenv.
+ */
+ eflags &= ~EV_NOKENV;
+ }
+
+ snprintf(env, sizeof(env), "%d", *cattr);
+ env_setenv(envname, eflags, env, sethook, unsethook);
+
+ return (from_env);
+}
+
+void
+gfx_fb_setcolors(teken_attr_t *attr, ev_sethook_t sethook,
+ ev_unsethook_t unsethook)
+{
+ const char *ptr;
+ bool need_setattr = false;
+
+ /*
+ * On first run, we setup an environment hook to process any color
+ * changes. If the env is already set, we pick up fg and bg color
+ * values from the environment.
+ */
+ if (gfx_fb_evalcolor("teken.fg_color", &attr->ta_fgcolor,
+ sethook, unsethook))
+ need_setattr = true;
+ if (gfx_fb_evalcolor("teken.bg_color", &attr->ta_bgcolor,
+ sethook, unsethook))
+ need_setattr = true;
+
+ if (need_setattr)
+ teken_set_defattr(&gfx_state.tg_teken, attr);
+}
+
static uint32_t
rgb_color_map(uint8_t index, uint32_t rmax, int roffset,
uint32_t gmax, int goffset, uint32_t bmax, int boffset)
diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h
index 17e419d8ffd3..d12bcd76b7fa 100644
--- a/stand/common/gfx_fb.h
+++ b/stand/common/gfx_fb.h
@@ -277,6 +277,7 @@ void gfx_fb_bezier(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
int gfx_fb_putimage(png_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
bool gfx_parse_mode_str(char *, int *, int *, int *);
+void gfx_fb_setcolors(teken_attr_t *, ev_sethook_t, ev_unsethook_t);
void term_image_display(teken_gfx_t *, const teken_rect_t *);
void reset_font_flags(void);
diff --git a/stand/common/misc.c b/stand/common/misc.c
index 402213100951..a7c46ad2e74c 100644
--- a/stand/common/misc.c
+++ b/stand/common/misc.c
@@ -220,3 +220,16 @@ set_currdev(const char *devname)
env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset,
env_nounset);
}
+
+#ifndef LOADER_NET_SUPPORT
+/*
+ * This api is normally provided by dev_net.c
+ * This stub keeps libsa happy when LOADER_NET_SUPPORT
+ * is not enabled.
+ */
+bool
+is_tftp(void)
+{
+ return false;
+}
+#endif
diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c
index 313469d32f35..1e39bd858cc2 100644
--- a/stand/common/modinfo.c
+++ b/stand/common/modinfo.c
@@ -172,6 +172,8 @@ md_copyenv(vm_offset_t start)
/* Traverse the environment. */
for (ep = environ; ep != NULL; ep = ep->ev_next) {
+ if ((ep->ev_flags & EV_NOKENV) != 0)
+ continue;
len = strlen(ep->ev_name);
if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len)
break;