graphics.c revision e7dd673d1e0acfe5420599588c559fd85a3a9e8f
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/*
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org>
* Copyright (C) 2012 Harald Hoyer <harald@redhat.com>
* Copyright (C) 2013 Intel Corporation
* Authored by Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
*/
#include <efi.h>
#include <efilib.h>
#include "util.h"
#include "graphics.h"
#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
{ 0xf42f7782, 0x12e, 0x4c12, { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } };
struct _EFI_CONSOLE_CONTROL_PROTOCOL;
typedef enum {
struct _EFI_CONSOLE_CONTROL_PROTOCOL *This,
);
struct _EFI_CONSOLE_CONTROL_PROTOCOL *This,
);
struct _EFI_CONSOLE_CONTROL_PROTOCOL *This,
);
typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL {
/* console control protocol is nonstandard and might not exist. */
}
/* check current mode */
err = uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, ¤t, &uga_exists, &stdin_locked);
return err;
/* do not touch the mode */
return EFI_SUCCESS;
/* some firmware enables the cursor when switching modes */
return err;
}
struct bmp_file {
} __attribute__((packed));
/* we require at least BITMAPINFOHEADER, later versions are
accepted, but their features ignored */
struct bmp_dib {
UINT32 x;
UINT32 y;
} __attribute__((packed));
struct bmp_map {
} __attribute__((packed));
return EFI_INVALID_PARAMETER;
/* check file header */
return EFI_INVALID_PARAMETER;
return EFI_INVALID_PARAMETER;
return EFI_INVALID_PARAMETER;
/* check device-independent bitmap */
return EFI_UNSUPPORTED;
case 1:
case 4:
case 8:
case 24:
if (dib->compression != 0)
return EFI_UNSUPPORTED;
break;
case 16:
case 32:
return EFI_UNSUPPORTED;
break;
default:
return EFI_UNSUPPORTED;
}
return EFI_INVALID_PARAMETER;
return EFI_INVALID_PARAMETER;
/* check color table */
return EFI_INVALID_PARAMETER;
if (dib->colors_used)
else {
case 1:
case 4:
case 8:
break;
default:
map_count = 0;
break;
}
}
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/* convert src from RGBA to XRGB */
/* decompose into RB and G components */
/* blend */
}
UINTN y;
/* transform and copy pixels */
for (y = 0; y < dib->y; y++) {
UINTN x;
case 1: {
UINTN i;
for (i = 0; i < 8 && x < dib->x; i++) {
out++;
x++;
}
out--;
x--;
break;
}
case 4: {
UINTN i;
i = (*in) >> 4;
if (x < (dib->x - 1)) {
out++;
x++;
i = (*in) & 0x0f;
}
break;
}
case 8:
break;
case 16: {
in += 1;
break;
}
case 24:
in += 2;
break;
case 32: {
in += 3;
break;
}
}
}
/* add row padding; new lines always start at 32 bit boundary */
}
return EFI_SUCCESS;
}
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) {
return err;
if (len < 0)
return EFI_LOAD_ERROR;
goto err;
EfiBltVideoFill, 0, 0, 0, 0,
/* EFI buffer */
if (!blt)
return EFI_OUT_OF_RESOURCES;
goto err;
goto err;
goto err;
err:
return err;
}