Skip to content

Commit

Permalink
Add const to a few more pointer types
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-gh committed Feb 16, 2019
1 parent f066946 commit 5dc1fb7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion android.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ EFI_STATUS android_open_image(struct android_image *image) {
return EFI_SUCCESS;
}

EFI_STATUS android_copy_cmdline(struct android_image *image, CHAR8* cmdline, UINTN max_length) {
EFI_STATUS android_copy_cmdline(const struct android_image *image, CHAR8* cmdline, UINTN max_length) {
if (max_length <= ANDROID_BOOT_ARGS_SIZE + ANDROID_BOOT_EXTRA_ARGS_SIZE) {
return EFI_BUFFER_TOO_SMALL;
}
Expand Down
12 changes: 6 additions & 6 deletions android.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ struct android_image {

EFI_STATUS android_open_image(struct android_image *image);

static inline EFI_STATUS android_read_kernel(struct android_image *image, UINT64 offset, VOID *kernel, UINTN size) {
static inline EFI_STATUS android_read_kernel(const struct android_image *image, UINT64 offset, VOID *kernel, UINTN size) {
return image_read(&image->image, image->header.page_size + offset, kernel, size);
}

static inline EFI_STATUS android_load_kernel(struct android_image *image, UINT64 offset, VOID *kernel) {
static inline EFI_STATUS android_load_kernel(const struct android_image *image, UINT64 offset, VOID *kernel) {
return android_read_kernel(image, offset, kernel, image->header.kernel_size - offset);
}

static inline UINT64 android_ramdisk_offset(struct android_image *image) {
static inline UINT64 android_ramdisk_offset(const struct android_image *image) {
UINTN mask = image->header.page_size - 1;
return image->header.page_size + ((image->header.kernel_size + mask) & ~mask);
}

static inline UINT32 android_ramdisk_size(struct android_image *image) {
static inline UINT32 android_ramdisk_size(const struct android_image *image) {
return image->header.ramdisk_size;
}

static inline EFI_STATUS android_load_ramdisk(struct android_image *image, VOID *ramdisk) {
static inline EFI_STATUS android_load_ramdisk(const struct android_image *image, VOID *ramdisk) {
return image_read(&image->image, android_ramdisk_offset(image), ramdisk, android_ramdisk_size(image));
}

EFI_STATUS android_copy_cmdline(struct android_image *image, CHAR8* cmdline, UINTN max_length);
EFI_STATUS android_copy_cmdline(const struct android_image *image, CHAR8* cmdline, UINTN max_length);

#endif //ANDROID_EFI_ANDROID_H
2 changes: 1 addition & 1 deletion graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static inline UINTN center(UINTN i, UINTN max) {
return i < max ? (max - i) / 2 : 0;
}

EFI_STATUS graphics_display_image(struct graphics_image *image) {
EFI_STATUS graphics_display_image(const struct graphics_image *image) {
EFI_GRAPHICS_OUTPUT_PROTOCOL *graphics_output;
EFI_STATUS err = LibLocateProtocol(&GraphicsOutputProtocol, (VOID**) &graphics_output);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ struct graphics_image {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *blt;
};

EFI_STATUS graphics_display_image(struct graphics_image *image);
EFI_STATUS graphics_display_image(const struct graphics_image *image);

#endif //ANDROID_EFI_GRAPHICS_H
12 changes: 6 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ static EFI_STATUS parse_command_line(EFI_LOADED_IMAGE_PROTOCOL *loaded_image, st
return err;
}

static EFI_STATUS prepare_cmdline(struct linux_setup_header *kernel_header, struct android_image *android_image,
struct android_efi_options *options) {
static EFI_STATUS prepare_cmdline(struct linux_setup_header *kernel_header, const struct android_image *android_image,
const struct android_efi_options *options) {
EFI_STATUS err = linux_allocate_cmdline(kernel_header);
if (err) {
return err;
Expand Down Expand Up @@ -243,7 +243,7 @@ static const CHAR8 *find_initrd_option(const CHAR8 *cmdline) {
}

static EFI_STATUS load_ramdisk_cmdline(EFI_HANDLE loader_device, const CHAR8 *cmdline,
struct linux_setup_header *kernel_header, struct android_image *android_image) {
struct linux_setup_header *kernel_header, const struct android_image *android_image) {
EFI_FILE_HANDLE dir = LibOpenRoot(loader_device);
if (!dir) {
Print(L"Failed to open root directory\n");
Expand Down Expand Up @@ -335,7 +335,7 @@ static EFI_STATUS load_ramdisk_cmdline(EFI_HANDLE loader_device, const CHAR8 *cm
}

static EFI_STATUS load_ramdisk(EFI_HANDLE loader_device,
struct linux_setup_header *kernel_header, struct android_image *android_image) {
struct linux_setup_header *kernel_header, const struct android_image *android_image) {
const CHAR8 *initrd = find_initrd_option(linux_cmdline_pointer(kernel_header));
if (initrd) {
return load_ramdisk_cmdline(loader_device, initrd, kernel_header, android_image);
Expand All @@ -350,7 +350,7 @@ static EFI_STATUS load_ramdisk(EFI_HANDLE loader_device,
}

static EFI_STATUS load_kernel(EFI_HANDLE loader, EFI_HANDLE loader_device,
struct android_efi_options *options, VOID **boot_params) {
const struct android_efi_options *options, VOID **boot_params) {
struct android_image android_image;
EFI_STATUS err = image_open(&android_image.image, loader, loader_device, options->partition_guid, options->path);
if (options->path) {
Expand Down Expand Up @@ -412,7 +412,7 @@ static EFI_STATUS load_kernel(EFI_HANDLE loader, EFI_HANDLE loader_device,
return err;
}

extern struct graphics_image splash_image;
extern const struct graphics_image splash_image;

EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) {
InitializeLib(image, system_table);
Expand Down
2 changes: 1 addition & 1 deletion png2efi/png2efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int write_image(const char *identifier, const char *filename, png_image *
}

fprintf(file, "};\n");
fprintf(file, "struct graphics_image %s_image = {%u, %u, %s_blt};\n",
fprintf(file, "const struct graphics_image %s_image = {%u, %u, %s_blt};\n",
identifier, image->width, image->height, identifier);

return fclose(file);
Expand Down

0 comments on commit 5dc1fb7

Please sign in to comment.