aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/Makefile1
-rw-r--r--com32/lib/sys/vesa/background.c46
-rw-r--r--com32/lib/syslinux/pxe_dns.c70
3 files changed, 108 insertions, 9 deletions
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index e66b6560..7bd340c1 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -109,6 +109,7 @@ LIBOBJS = \
syslinux/initramfs_archive.o \
\
syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
+ syslinux/pxe_dns.o \
\
syslinux/adv.o syslinux/advwrite.o syslinux/getadv.o \
syslinux/setadv.o \
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c
index 2e573846..8d732395 100644
--- a/com32/lib/sys/vesa/background.c
+++ b/com32/lib/sys/vesa/background.c
@@ -75,26 +75,54 @@ static void draw_background(void)
__vesacon_redraw_text();
}
+/*
+ * Tile an image in the UL corner across the entire screen
+ */
+static void tile_image(int width, int height)
+{
+ int xsize = __vesa_info.mi.h_res;
+ int ysize = __vesa_info.mi.v_res;
+ int x, y, yr;
+ int xl, yl;
+ uint32_t *sp, *dp, *drp, *dtp;
+
+ drp = __vesacon_background;
+ for (y = 0 ; y < ysize ; y += height) {
+ yl = min(height, ysize-y);
+ dtp = drp;
+ for (x = 0 ; x < xsize ; x += width) {
+ xl = min(width, xsize-x);
+ if (x || y) {
+ sp = __vesacon_background;
+ dp = dtp;
+ for (yr = 0 ; yr < yl ; yr++) {
+ memcpy(dp, sp, xl*sizeof(uint32_t));
+ dp += xsize;
+ sp += xsize;
+ }
+ }
+ dtp += xl;
+ }
+ drp += xsize*height;
+ }
+}
+
static int read_png_file(FILE * fp)
{
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
- png_infop end_ptr = NULL;
#if 0
png_color_16p image_background;
static const png_color_16 my_background = { 0, 0, 0, 0, 0 };
#endif
png_bytep row_pointers[__vesa_info.mi.v_res], rp;
- int passes;
int i;
int rv = -1;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-
info_ptr = png_create_info_struct(png_ptr);
- end_ptr = png_create_info_struct(png_ptr);
- if (!png_ptr || !info_ptr || !end_ptr || setjmp(png_jmpbuf(png_ptr)))
+ if (!png_ptr || !info_ptr || setjmp(png_jmpbuf(png_ptr)))
goto err;
png_init_io(png_ptr, fp);
@@ -146,16 +174,15 @@ static int read_png_file(FILE * fp)
rp += __vesa_info.mi.h_res << 2;
}
- passes = png_set_interlace_handling(png_ptr);
+ png_read_image(png_ptr, row_pointers);
- for (i = 0; i < passes; i++)
- png_read_rows(png_ptr, row_pointers, NULL, info_ptr->height);
+ tile_image(info_ptr->width, info_ptr->height);
rv = 0;
err:
if (png_ptr)
- png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
return rv;
}
@@ -198,6 +225,7 @@ static int read_jpeg_file(FILE * fp, uint8_t * header, int len)
tinyjpeg_set_bytes_per_row(jdec, bytes_per_row, 1);
tinyjpeg_decode(jdec, TINYJPEG_FMT_BGRA32);
+ tile_image(width, height);
rv = 0;
diff --git a/com32/lib/syslinux/pxe_dns.c b/com32/lib/syslinux/pxe_dns.c
new file mode 100644
index 00000000..9ab95137
--- /dev/null
+++ b/com32/lib/syslinux/pxe_dns.c
@@ -0,0 +1,70 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2010 Intel Corporation; author: H. Peter Anvin
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * pxe_dns.c
+ *
+ * Resolve a hostname via DNS
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <com32.h>
+
+#include <syslinux/pxe.h>
+
+/* Returns the status code from PXE (0 on success),
+ or -1 on invocation failure */
+uint32_t pxe_dns(const char *hostname)
+{
+ com32sys_t regs;
+ union {
+ unsigned char b[4];
+ uint32_t ip;
+ } q;
+
+ /* Is this a dot-quad? */
+ if (sscanf(hostname, "%hhu.%hhu.%hhu.%hhu",
+ &q.b[0], &q.b[1], &q.b[2], &q.b[3]) == 4)
+ return q.ip;
+
+ memset(&regs, 0, sizeof regs);
+ regs.eax.w[0] = 0x0010;
+ regs.es = SEG(__com32.cs_bounce);
+ regs.ebx.w[0] = OFFS(__com32.cs_bounce);
+
+ strcpy((char *)__com32.cs_bounce, hostname);
+
+ __intcall(0x22, &regs, &regs);
+
+ if (regs.eflags.l & EFLAGS_CF)
+ return 0;
+
+ return regs.eax.l;
+}