summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-05 13:01:02 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-05 13:01:13 +0000
commitcdeba8ac82f529a3a4a544c4e8346887ef81cb74 (patch)
tree611495b677f618d9adc1566bc34c41e1405b00c0
parent90be055dcd959eecb0253e6e7a699a074a6f345f (diff)
parentfc8f32cbea0692c0d130bb596107373c1dd30222 (diff)
downloadsyslinux-cdeba8ac82f529a3a4a544c4e8346887ef81cb74.tar.gz
Merge branch 'cleanup' into for-hpa/elflink/firmware
-rw-r--r--Makefile9
-rw-r--r--com32/include/com32.h2
-rw-r--r--com32/lib/sys/vesa/efi/i915resolution.c2
-rw-r--r--com32/lib/sys/vesa/efi/initvesa.c258
-rw-r--r--com32/lib/sys/vesa/efi/screencpy.c87
-rw-r--r--com32/lib/sys/vesa/initvesa.c8
-rw-r--r--com32/lib/sys/vesa/video.h2
-rw-r--r--efi/diskio.c3
-rw-r--r--efi/efi.h4
9 files changed, 16 insertions, 359 deletions
diff --git a/Makefile b/Makefile
index 15d0a981..a4daae54 100644
--- a/Makefile
+++ b/Makefile
@@ -247,14 +247,7 @@ all-local: $(BTARGET) $(ITARGET)
-ls -l $(BOBJECTS) $(IOBJECTS)
subdirs: $(BSUBDIRS) $(ISUBDIRS)
-# Note the double-colon which avoids the make warning about redefining
-# a rule for libinstaller.
-$(BSUBDIRS):
- @mkdir -p $@
- $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
- -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
-
-$(ISUBDIRS):
+$(sort $(ISUBDIRS) $(BSUBDIRS)):
@mkdir -p $@
$(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
-f $(SRC)/$@/Makefile $(MAKECMDGOALS)
diff --git a/com32/include/com32.h b/com32/include/com32.h
index 7ca187a5..c5d60176 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -176,7 +176,7 @@ static inline bool _OFFS_VALID(const volatile void *__p, size_t __s,
static inline void *MK_PTR(uint16_t __seg, uint16_t __offs)
{
- return (void *)((__seg << 4) + __offs);
+ return (void *)(unsigned long)((__seg << 4) + __offs);
}
/* Some tools to handle 16:16 far pointers in memory */
diff --git a/com32/lib/sys/vesa/efi/i915resolution.c b/com32/lib/sys/vesa/efi/i915resolution.c
index 6ebb04d3..ac66175f 100644
--- a/com32/lib/sys/vesa/efi/i915resolution.c
+++ b/com32/lib/sys/vesa/efi/i915resolution.c
@@ -443,7 +443,7 @@ static vbios_map * open_vbios(void)
}
else {
debug("Unable to determine bios type.\r\n");
- debug("Mode Table Offset: $C0000 + $%x\r\n", ((unsigned int)map->mode_table) - ((unsigned int)map->bios_ptr));
+ debug("Mode Table Offset: $C0000 + $%x\r\n", ((unsigned long)map->mode_table) - ((unsigned long)map->bios_ptr));
debug("Mode Table Entries: %u\r\n", map->mode_table_size);
bad_marker(0x15);
return NULL;
diff --git a/com32/lib/sys/vesa/efi/initvesa.c b/com32/lib/sys/vesa/efi/initvesa.c
index 2144f142..83673c1e 100644
--- a/com32/lib/sys/vesa/efi/initvesa.c
+++ b/com32/lib/sys/vesa/efi/initvesa.c
@@ -80,241 +80,6 @@ static void unpack_font(uint8_t * dst, uint8_t * src, int height)
}
}
-static int __constfunc is_power_of_2(unsigned int x)
-{
- return x && !(x & (x - 1));
-}
-
-static int vesacon_paged_mode_ok(const struct vesa_mode_info *mi)
-{
- int i;
-
- if (!is_power_of_2(mi->win_size) ||
- !is_power_of_2(mi->win_grain) || mi->win_grain > mi->win_size)
- return 0; /* Impossible... */
-
- for (i = 0; i < 2; i++) {
- if ((mi->win_attr[i] & 0x05) == 0x05 && mi->win_seg[i])
- return 1; /* Usable window */
- }
-
- return 0; /* Nope... */
-}
-
-#ifndef SYSLINUX_EFI
-static int vesacon_set_mode(int *x, int *y)
-{
- com32sys_t rm;
- uint8_t *rom_font;
- uint16_t mode, bestmode, *mode_ptr;
- struct vesa_info *vi;
- struct vesa_general_info *gi;
- struct vesa_mode_info *mi;
- enum vesa_pixel_format pxf, bestpxf;
- int err = 0;
-
- debug("Hello, World!\r\n");
-
- /* Free any existing data structures */
- if (__vesacon_background) {
- free(__vesacon_background);
- __vesacon_background = NULL;
- }
- if (__vesacon_shadowfb) {
- free(__vesacon_shadowfb);
- __vesacon_shadowfb = NULL;
- }
-
- /* Allocate space in the bounce buffer for these structures */
- vi = lzalloc(sizeof *vi);
- if (!vi) {
- err = 10; /* Out of memory */
- goto exit;
- }
- gi = &vi->gi;
- mi = &vi->mi;
-
- memset(&rm, 0, sizeof rm);
-
- gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
- rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
- rm.edi.w[0] = OFFS(gi);
- rm.es = SEG(gi);
- __intcall(0x10, &rm, &rm);
-
- if (rm.eax.w[0] != 0x004F) {
- err = 1; /* Function call failed */
- goto exit;
- }
- if (gi->signature != VESA_MAGIC) {
- err = 2; /* No magic */
- goto exit;
- }
- if (gi->version < 0x0102) {
- err = 3; /* VESA 1.2+ required */
- goto exit;
- }
-
- /* Copy general info */
- memcpy(&__vesa_info.gi, gi, sizeof *gi);
-
- /* Search for the proper mode with a suitable color and memory model... */
-
- mode_ptr = GET_PTR(gi->video_mode_ptr);
- bestmode = 0;
- bestpxf = PXF_NONE;
-
- while ((mode = *mode_ptr++) != 0xFFFF) {
- mode &= 0x1FF; /* The rest are attributes of sorts */
-
- debug("Found mode: 0x%04x\r\n", mode);
-
- memset(mi, 0, sizeof *mi);
- rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
- rm.ecx.w[0] = mode;
- rm.edi.w[0] = OFFS(mi);
- rm.es = SEG(mi);
- __intcall(0x10, &rm, &rm);
-
- /* Must be a supported mode */
- if (rm.eax.w[0] != 0x004f)
- continue;
-
- debug
- ("mode_attr 0x%04x, h_res = %4d, v_res = %4d, bpp = %2d, layout = %d (%d,%d,%d)\r\n",
- mi->mode_attr, mi->h_res, mi->v_res, mi->bpp, mi->memory_layout,
- mi->rpos, mi->gpos, mi->bpos);
-
- /* Must be an LFB color graphics mode supported by the hardware.
-
- The bits tested are:
- 4 - graphics mode
- 3 - color mode
- 1 - mode information available (mandatory in VBE 1.2+)
- 0 - mode supported by hardware
- */
- if ((mi->mode_attr & 0x001b) != 0x001b)
- continue;
-
- /* Must be the chosen size */
- if (mi->h_res != *x || mi->v_res != *y)
- continue;
-
- /* We don't support multibank (interlaced memory) modes */
- /*
- * Note: The Bochs VESA BIOS (vbe.c 1.58 2006/08/19) violates the
- * specification which states that banks == 1 for unbanked modes;
- * fortunately it does report bank_size == 0 for those.
- */
- if (mi->banks > 1 && mi->bank_size) {
- debug("bad: banks = %d, banksize = %d, pages = %d\r\n",
- mi->banks, mi->bank_size, mi->image_pages);
- continue;
- }
-
- /* Must be either a flat-framebuffer mode, or be an acceptable
- paged mode */
- if (!(mi->mode_attr & 0x0080) && !vesacon_paged_mode_ok(mi)) {
- debug("bad: invalid paged mode\r\n");
- continue;
- }
-
- /* Must either be a packed-pixel mode or a direct color mode
- (depending on VESA version ); must be a supported pixel format */
- pxf = PXF_NONE; /* Not usable */
-
- if (mi->bpp == 32 &&
- (mi->memory_layout == 4 ||
- (mi->memory_layout == 6 && mi->rpos == 16 && mi->gpos == 8 &&
- mi->bpos == 0)))
- pxf = PXF_BGRA32;
- else if (mi->bpp == 24 &&
- (mi->memory_layout == 4 ||
- (mi->memory_layout == 6 && mi->rpos == 16 && mi->gpos == 8 &&
- mi->bpos == 0)))
- pxf = PXF_BGR24;
- else if (mi->bpp == 16 &&
- (mi->memory_layout == 4 ||
- (mi->memory_layout == 6 && mi->rpos == 11 && mi->gpos == 5 &&
- mi->bpos == 0)))
- pxf = PXF_LE_RGB16_565;
- else if (mi->bpp == 15 &&
- (mi->memory_layout == 4 ||
- (mi->memory_layout == 6 && mi->rpos == 10 && mi->gpos == 5 &&
- mi->bpos == 0)))
- pxf = PXF_LE_RGB15_555;
-
- if (pxf < bestpxf) {
- debug("Best mode so far, pxf = %d\r\n", pxf);
-
- /* Best mode so far... */
- bestmode = mode;
- bestpxf = pxf;
-
- /* Copy mode info */
- memcpy(&__vesa_info.mi, mi, sizeof *mi);
- }
- }
-
- if (bestpxf == PXF_NONE) {
- err = 4; /* No mode found */
- goto exit;
- }
-
- mi = &__vesa_info.mi;
- mode = bestmode;
- __vesacon_bytes_per_pixel = (mi->bpp + 7) >> 3;
- __vesacon_format_pixels = __vesacon_format_pixels_list[bestpxf];
-
- /* Download the SYSLINUX- or BIOS-provided font */
- __vesacon_font_height = syslinux_font_query(&rom_font);
- if (!__vesacon_font_height) {
- /* Get BIOS 8x16 font */
-
- rm.eax.w[0] = 0x1130; /* Get Font Information */
- rm.ebx.w[0] = 0x0600; /* Get 8x16 ROM font */
- __intcall(0x10, &rm, &rm);
- rom_font = MK_PTR(rm.es, rm.ebp.w[0]);
- __vesacon_font_height = 16;
- }
- unpack_font((uint8_t *) __vesacon_graphics_font, rom_font,
- __vesacon_font_height);
-
- /* Now set video mode */
- rm.eax.w[0] = 0x4F02; /* Set SVGA video mode */
- if (mi->mode_attr & 0x0080)
- mode |= 0x4000; /* Request linear framebuffer if supported */
- rm.ebx.w[0] = mode;
- __intcall(0x10, &rm, &rm);
- if (rm.eax.w[0] != 0x004F) {
- err = 9; /* Failed to set mode */
- goto exit;
- }
-
- __vesacon_background = calloc(mi->h_res*mi->v_res, 4);
- __vesacon_shadowfb = calloc(mi->h_res*mi->v_res, 4);
-
- __vesacon_init_copy_to_screen();
-
- /* Tell syslinux we changed video mode */
- /* In theory this should be:
-
- flags = (mi->mode_attr & 4) ? 0x0007 : 0x000f;
-
- However, that would assume all systems that claim to handle text
- output in VESA modes actually do that... */
- syslinux_report_video_mode(0x000f, mi->h_res, mi->v_res);
-
- __vesacon_pixel_format = bestpxf;
-
-exit:
- if (vi)
- lfree(vi);
-
- return err;
-}
-
-#else
/* EFI GOP support
* Note GOP support uses the VESA info structure as much as possible and
* extends it as needed for EFI support. Not all of the vesa info structure
@@ -350,9 +115,8 @@ static int vesacon_set_mode(int *x, int *y)
BOOLEAN mode_match = FALSE;
UINTN sz_info;
struct vesa_info *vi;
- struct vesa_general_info *gi;
struct vesa_mode_info *mi;
- enum vesa_pixel_format pxf, bestpxf = PXF_NONE;
+ enum vesa_pixel_format bestpxf = PXF_NONE;
int err = 0;
//debug("Hello, World!\r\n");
@@ -408,7 +172,6 @@ static int vesacon_set_mode(int *x, int *y)
goto exit;
}
/* Note that the generic info is untouched as we don't find any relevance to EFI */
- gi = &vi->gi;
mi = &vi->mi;
/* Set up mode-specific information */
mi->h_res = *x;
@@ -508,7 +271,8 @@ static int vesacon_set_mode(int *x, int *y)
* file support should be exposed via firmware structure)
*/
__vesacon_font_height = cp865_8x16_font_height;
- unpack_font((uint8_t *) __vesacon_graphics_font, cp865_8x16_font_data,
+ unpack_font((uint8_t *) __vesacon_graphics_font,
+ (uint8_t *)cp865_8x16_font_data,
__vesacon_font_height);
/* Free any existing data structures */
@@ -572,7 +336,6 @@ exit:
return err;
}
-#endif /* SYSLINUX_EFI */
/* FIXME:
* Does init_text_display need an EFI counterpart?
@@ -617,25 +380,12 @@ static int init_text_display(void)
*/
int __vesacon_init(int *x, int *y)
{
- int rv;
-
/* We need the FPU for graphics, at least libpng et al will need it... */
if (x86_init_fpu())
return 10;
- rv = vesacon_set_mode(x, y);
- /* FIXME: Accessing Video BIOS from EFI will probably not work */
-#ifndef SYSLINUX_EFI
- if (rv) {
- /* Try to see if we can just patch the BIOS... */
- if (__vesacon_i915resolution(*x, *y))
- return rv;
- if (vesacon_set_mode(x, y))
- return rv;
- }
-#else
+ vesacon_set_mode(x, y);
/* FIXME: Accessing Video BIOS from EFI will probably not work, skip it for now */
-#endif
init_text_display();
diff --git a/com32/lib/sys/vesa/efi/screencpy.c b/com32/lib/sys/vesa/efi/screencpy.c
index aa650cc3..2e191c7e 100644
--- a/com32/lib/sys/vesa/efi/screencpy.c
+++ b/com32/lib/sys/vesa/efi/screencpy.c
@@ -42,85 +42,9 @@ static struct win_info {
int win_num;
} wi;
-#ifndef SYSLINUX_EFI
void __vesacon_init_copy_to_screen(void)
{
struct vesa_mode_info *const mi = &__vesa_info.mi;
- int winn;
-
- if (mi->mode_attr & 0x0080) {
- /* Linear frame buffer */
-
- wi.win_base = (char *)mi->lfb_ptr;
- wi.win_size = 1 << 31; /* 2 GB, i.e. one huge window */
- wi.win_pos = 0; /* Already positioned (only one position...) */
- wi.win_num = -1; /* Not a window */
- } else {
- /* Paged frame buffer */
-
- /* We have already tested that *one* of these is usable */
- if ((mi->win_attr[0] & 0x05) == 0x05 && mi->win_seg[0])
- winn = 0;
- else
- winn = 1;
-
- wi.win_num = winn;
- wi.win_base = (char *)(mi->win_seg[winn] << 4);
- wi.win_size = mi->win_size << 10;
- wi.win_gshift = ilog2(mi->win_grain) + 10;
- wi.win_pos = -1; /* Undefined position */
- }
-}
-
-static void set_window_pos(size_t win_pos)
-{
- static com32sys_t ireg;
-
- wi.win_pos = win_pos;
-
- if (wi.win_num < 0)
- return; /* This should never happen... */
-
- ireg.eax.w[0] = 0x4F05;
- ireg.ebx.b[0] = wi.win_num;
- ireg.edx.w[0] = win_pos >> wi.win_gshift;
-
- __intcall(0x10, &ireg, NULL);
-}
-
-void __vesacon_copy_to_screen(size_t dst, const uint32_t * src, size_t npixels)
-{
- size_t win_pos, win_off;
- size_t win_size = wi.win_size;
- size_t omask = win_size - 1;
- char *win_base = wi.win_base;
- size_t l;
- size_t bytes = npixels * __vesacon_bytes_per_pixel;
- char rowbuf[bytes + 4] __aligned(4);
- const char *s;
-
- s = (const char *)__vesacon_format_pixels(rowbuf, src, npixels);
-
- while (bytes) {
- win_off = dst & omask;
- win_pos = dst & ~omask;
-
- if (__unlikely(win_pos != wi.win_pos))
- set_window_pos(win_pos);
-
- l = min(bytes, win_size - win_off);
- memcpy(win_base + win_off, s, l);
-
- bytes -= l;
- s += l;
- dst += l;
- }
-}
-#else
-void __vesacon_init_copy_to_screen(void)
-{
- struct vesa_mode_info *const mi = &__vesa_info.mi;
- int winn;
if (mi->mode_attr & 0x0080) {
/* Linear frame buffer */
@@ -133,18 +57,10 @@ void __vesacon_init_copy_to_screen(void)
/* FIXME: PixelBltOnly mode is unsupported */
}
-/* FIXME: Nothing to do for EFI */
-static void set_window_pos(size_t win_pos)
-{
-}
-
void __vesacon_copy_to_screen(size_t dst, const uint32_t * src, size_t npixels)
{
- size_t win_pos, win_off;
- size_t win_size = wi.win_size;
- size_t omask = win_size - 1;
+ size_t win_off;
char *win_base = wi.win_base;
- size_t l;
size_t bytes = npixels * __vesacon_bytes_per_pixel;
char rowbuf[bytes + 4] __aligned(4);
const char *s;
@@ -157,4 +73,3 @@ void __vesacon_copy_to_screen(size_t dst, const uint32_t * src, size_t npixels)
win_off = dst;
memcpy(win_base + win_off, s, bytes);
}
-#endif /* SYSLINUX_EFI */
diff --git a/com32/lib/sys/vesa/initvesa.c b/com32/lib/sys/vesa/initvesa.c
index 9a1ae384..d227629d 100644
--- a/com32/lib/sys/vesa/initvesa.c
+++ b/com32/lib/sys/vesa/initvesa.c
@@ -329,7 +329,7 @@ static int init_text_display(void)
return 0;
}
-int __vesacon_init(int x, int y)
+int __vesacon_init(int *x, int *y)
{
int rv;
@@ -337,12 +337,12 @@ int __vesacon_init(int x, int y)
if (x86_init_fpu())
return 10;
- rv = vesacon_set_mode(x, y);
+ rv = vesacon_set_mode(*x, *y);
if (rv) {
/* Try to see if we can just patch the BIOS... */
- if (__vesacon_i915resolution(x, y))
+ if (__vesacon_i915resolution(*x, *y))
return rv;
- if (vesacon_set_mode(x, y))
+ if (vesacon_set_mode(*x, *y))
return rv;
}
diff --git a/com32/lib/sys/vesa/video.h b/com32/lib/sys/vesa/video.h
index d14494b1..de068457 100644
--- a/com32/lib/sys/vesa/video.h
+++ b/com32/lib/sys/vesa/video.h
@@ -81,7 +81,7 @@ extern const uint8_t __vesacon_linear_to_srgb[4080];
int __vesacon_init_background(void);
int vesacon_load_background(const char *);
-int __vesacon_init(int, int);
+int __vesacon_init(int *, int *);
void __vesacon_init_cursor(int);
void __vesacon_erase(int, int, int, int, attr_t);
void __vesacon_scroll_up(int, attr_t);
diff --git a/efi/diskio.c b/efi/diskio.c
index a4d558a4..27745a92 100644
--- a/efi/diskio.c
+++ b/efi/diskio.c
@@ -21,7 +21,6 @@ static int efi_rdwr_sectors(struct disk *disk, void *buf,
{
struct disk_private *priv = disk->private;
EFI_BLOCK_IO *bio = priv->bio;
- EFI_DISK_IO *dio = priv->dio;
EFI_STATUS status;
UINTN bytes = count * disk->sector_size;
@@ -43,11 +42,9 @@ struct disk *efi_disk_init(struct disk_private *priv)
{
static struct disk disk;
EFI_HANDLE handle = priv->dev_handle;
- unsigned int hard_max_transfer;
EFI_BLOCK_IO *bio;
EFI_DISK_IO *dio;
EFI_STATUS status;
- int sector_size;
status = uefi_call_wrapper(BS->HandleProtocol, 3, handle,
&DiskIoProtocol, (void **)&dio);
diff --git a/efi/efi.h b/efi/efi.h
index 8ffe5332..cab49852 100644
--- a/efi/efi.h
+++ b/efi/efi.h
@@ -9,6 +9,8 @@
#include <efistdarg.h>
extern EFI_HANDLE image_handle;
-void setup_screen(struct screen_info *); /* fix build error */
+
+struct screen_info;
+extern void setup_screen(struct screen_info *);
#endif /* _SYSLINUX_EFI_H */