wok-6.x annotate linux/stuff/linux-efi.u @ rev 23548

Up bcrelay (1.4.0)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Apr 06 17:04:09 2020 +0000 (2020-04-06)
parents 02ed2446b480
children
rev   line source
pascal@20333 1 --- linux-3.16.53/drivers/firmware/efi/efi-stub-helper.c
pascal@20333 2 +++ linux-3.16.53/drivers/firmware/efi/efi-stub-helper.c
pascal@20337 3 @@ -321,6 +321,79 @@
pascal@20333 4
pascal@20333 5
pascal@20333 6 /*
pascal@20333 7 + *
pascal@20333 8 + */
pascal@20333 9 +static efi_status_t get_file_size(efi_system_table_t *sys_table_arg,
pascal@20333 10 + efi_loaded_image_t *image,
pascal@20333 11 + efi_char16_t *filename_16,
pascal@20333 12 + struct file_info *file)
pascal@20333 13 +{
pascal@20333 14 + efi_status_t status;
pascal@20333 15 + efi_file_handle_t *fh = NULL;
pascal@20333 16 +#ifdef CONFIG_X86_64
pascal@20333 17 + efi_char16_t *p, c;
pascal@20333 18 +#endif
pascal@20333 19 +
pascal@20333 20 + /* Only open the volume once. */
pascal@20333 21 + if (!fh) {
pascal@20333 22 + status = efi_open_volume(sys_table_arg, image,
pascal@20333 23 + (void **)&fh);
pascal@20333 24 + if (status != EFI_SUCCESS)
pascal@20333 25 + return status;
pascal@20333 26 + }
pascal@20333 27 +#ifdef CONFIG_X86_64
pascal@20333 28 + for (p = filename_16; *p != '\0'; p++);
pascal@20333 29 + c = p[-2];
pascal@20337 30 + file->size = EFI_FILE_SIZE_MUTE;
pascal@20333 31 + while (1) {
pascal@20333 32 +#endif
pascal@20333 33 + status = efi_file_size(sys_table_arg, fh, filename_16,
pascal@20333 34 + (void **)&file->handle, &file->size);
pascal@20333 35 +#ifdef CONFIG_X86_64
pascal@20333 36 + if (status != EFI_SUCCESS && p[-2] != '\0') {
pascal@20333 37 + p[-2] = '\0';
pascal@20337 38 + file->size++;
pascal@20333 39 + continue;
pascal@20333 40 + }
pascal@20333 41 + break;
pascal@20333 42 + }
pascal@20333 43 + p[-2] = c;
pascal@20333 44 +#endif
pascal@20333 45 + return status;
pascal@20333 46 +}
pascal@20333 47 +
pascal@20333 48 +/*
pascal@20333 49 + *
pascal@20333 50 + */
pascal@20333 51 +static efi_status_t read_efi_file(efi_system_table_t *sys_table_arg,
pascal@20333 52 + struct file_info *file,
pascal@20333 53 + unsigned long addr,
pascal@20333 54 + unsigned long size)
pascal@20333 55 +{
pascal@20333 56 + efi_status_t status;
pascal@20333 57 +
pascal@20333 58 + while (size) {
pascal@20333 59 + unsigned long chunksize;
pascal@20333 60 + if (size > EFI_READ_CHUNK_SIZE)
pascal@20333 61 + chunksize = EFI_READ_CHUNK_SIZE;
pascal@20333 62 + else
pascal@20333 63 + chunksize = size;
pascal@20333 64 +
pascal@20333 65 + status = efi_file_read(file->handle,
pascal@20333 66 + &chunksize,
pascal@20333 67 + (void *)addr);
pascal@20333 68 + if (status != EFI_SUCCESS) {
pascal@20333 69 + pr_efi_err(sys_table_arg, "Failed to read file\n");
pascal@20333 70 + break;
pascal@20333 71 + }
pascal@20333 72 + addr += chunksize;
pascal@20333 73 + size -= chunksize;
pascal@20333 74 + }
pascal@20333 75 + efi_file_close(file->handle);
pascal@20333 76 + return status;
pascal@20333 77 +}
pascal@20333 78 +
pascal@20333 79 +/*
pascal@20333 80 * Check the cmdline for a LILO-style file= arguments.
pascal@20333 81 *
pascal@20333 82 * We only support loading a file from the same filesystem as
pascal@20337 83 @@ -414,18 +487,14 @@
pascal@20333 84 }
pascal@20333 85 }
pascal@20333 86
pascal@20333 87 +#ifdef CONFIG_X86_64
pascal@20333 88 + *p++ = '6';
pascal@20333 89 + *p++ = '4';
pascal@20333 90 +#endif
pascal@20333 91 *p = '\0';
pascal@20333 92
pascal@20333 93 - /* Only open the volume once. */
pascal@20333 94 - if (!i) {
pascal@20333 95 - status = efi_open_volume(sys_table_arg, image,
pascal@20333 96 - (void **)&fh);
pascal@20333 97 - if (status != EFI_SUCCESS)
pascal@20333 98 - goto free_files;
pascal@20333 99 - }
pascal@20333 100 -
pascal@20333 101 - status = efi_file_size(sys_table_arg, fh, filename_16,
pascal@20333 102 - (void **)&file->handle, &file->size);
pascal@20333 103 + status = get_file_size(sys_table_arg,image,filename_16,file);
pascal@20333 104 +
pascal@20333 105 if (status != EFI_SUCCESS)
pascal@20333 106 goto close_handles;
pascal@20333 107
pascal@20337 108 @@ -456,28 +525,11 @@
pascal@20333 109
pascal@20334 110 addr = file_addr;
pascal@20333 111 for (j = 0; j < nr_files; j++) {
pascal@20333 112 - unsigned long size;
pascal@20333 113 -
pascal@20333 114 - size = files[j].size;
pascal@20333 115 - while (size) {
pascal@20333 116 - unsigned long chunksize;
pascal@20333 117 - if (size > EFI_READ_CHUNK_SIZE)
pascal@20333 118 - chunksize = EFI_READ_CHUNK_SIZE;
pascal@20333 119 - else
pascal@20333 120 - chunksize = size;
pascal@20333 121 -
pascal@20333 122 - status = efi_file_read(files[j].handle,
pascal@20333 123 - &chunksize,
pascal@20333 124 - (void *)addr);
pascal@20333 125 - if (status != EFI_SUCCESS) {
pascal@20333 126 - pr_efi_err(sys_table_arg, "Failed to read file\n");
pascal@20333 127 - goto free_file_total;
pascal@20333 128 - }
pascal@20333 129 - addr += chunksize;
pascal@20333 130 - size -= chunksize;
pascal@20333 131 - }
pascal@20333 132 -
pascal@20333 133 - efi_file_close(files[j].handle);
pascal@20334 134 + status = read_efi_file(sys_table_arg, &files[j], addr, files[j].size);
pascal@20333 135 + if (status != EFI_SUCCESS)
pascal@20333 136 + goto free_file_total;
pascal@20334 137 + addr += files[j].size + 3;
pascal@20334 138 + addr &= 0xFFFFFFFCUL;
pascal@20333 139 }
pascal@20333 140
pascal@20333 141 }
pascal@20337 142 @@ -649,6 +701,30 @@
pascal@20333 143 }
pascal@20333 144
pascal@20333 145 if (!options_chars) {
pascal@20333 146 + /* No command line options, look for linux.cmdline */
pascal@20333 147 +#ifdef CONFIG_X86_64
pascal@20333 148 +#define cmdline_name L"EFI\\BOOT\\linux.cmdline64"
pascal@20333 149 +#else
pascal@20333 150 +#define cmdline_name L"EFI\\BOOT\\linux.cmdline"
pascal@20333 151 +#endif
pascal@20333 152 + struct file_info file;
pascal@20333 153 + efi_char16_t filename_16[sizeof(cmdline_name)];
pascal@20333 154 +
pascal@20333 155 + memcpy((void *)filename_16, (void *)cmdline_name, sizeof(cmdline_name));
pascal@20333 156 + if (get_file_size(sys_table_arg, image, filename_16, &file) != EFI_SUCCESS)
pascal@20333 157 + goto no_cmdline_file;
pascal@20333 158 +
pascal@20333 159 + options_bytes = file.size+1;
pascal@20333 160 + if (efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr) != EFI_SUCCESS)
pascal@20333 161 + goto no_cmdline_file;
pascal@20333 162 +
pascal@20333 163 + *((u8 *)cmdline_addr + file.size) = '\0';
pascal@20333 164 + if (read_efi_file(sys_table_arg, &file, cmdline_addr, file.size) == EFI_SUCCESS)
pascal@20333 165 + goto return_cmdline;
pascal@20333 166 + }
pascal@20333 167 + no_cmdline_file:
pascal@20333 168 +
pascal@20333 169 + if (!options_chars) {
pascal@20333 170 /* No command line options, so return empty string*/
pascal@20333 171 options = &zero;
pascal@20333 172 }
pascal@20337 173 @@ -665,6 +741,7 @@
pascal@20333 174 s1 = efi_utf16_to_utf8(s1, s2, options_chars);
pascal@20333 175 *s1 = '\0';
pascal@20333 176
pascal@20333 177 +return_cmdline:
pascal@20333 178 *cmd_line_len = options_bytes;
pascal@20333 179 return (char *)cmdline_addr;
pascal@20333 180 }
pascal@20337 181 --- linux-3.16.53/arch/x86/boot/compressed/eboot.c
pascal@20337 182 +++ linux-3.16.53/arch/x86/boot/compressed/eboot.c
pascal@20337 183 @@ -51,6 +51,7 @@
pascal@20337 184 static void efi_printk(efi_system_table_t *, char *);
pascal@20337 185 static void efi_char16_printk(efi_system_table_t *, efi_char16_t *);
pascal@20337 186
pascal@20337 187 +#define EFI_FILE_SIZE_MUTE 0x4554554d20525245LL
pascal@20337 188 static efi_status_t
pascal@20337 189 __file_size32(void *__fh, efi_char16_t *filename_16,
pascal@20337 190 void **handle, u64 *file_sz)
pascal@20337 191 @@ -64,9 +65,11 @@
pascal@20337 192 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16,
pascal@20337 193 EFI_FILE_MODE_READ, (u64)0);
pascal@20337 194 if (status != EFI_SUCCESS) {
pascal@20337 195 - efi_printk(sys_table, "Failed to open file: ");
pascal@20337 196 - efi_char16_printk(sys_table, filename_16);
pascal@20337 197 - efi_printk(sys_table, "\n");
pascal@20337 198 + if (*file_sz != EFI_FILE_SIZE_MUTE) {
pascal@20337 199 + efi_printk(sys_table, "Failed to open file: ");
pascal@20337 200 + efi_char16_printk(sys_table, filename_16);
pascal@20337 201 + efi_printk(sys_table, "\n");
pascal@20337 202 + }
pascal@20337 203 return status;
pascal@20337 204 }
pascal@20337 205
pascal@20337 206 @@ -117,9 +120,11 @@
pascal@20337 207 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16,
pascal@20337 208 EFI_FILE_MODE_READ, (u64)0);
pascal@20337 209 if (status != EFI_SUCCESS) {
pascal@20337 210 - efi_printk(sys_table, "Failed to open file: ");
pascal@20337 211 - efi_char16_printk(sys_table, filename_16);
pascal@20337 212 - efi_printk(sys_table, "\n");
pascal@20337 213 + if (*file_sz != EFI_FILE_SIZE_MUTE) {
pascal@20337 214 + efi_printk(sys_table, "Failed to open file: ");
pascal@20337 215 + efi_char16_printk(sys_table, filename_16);
pascal@20337 216 + efi_printk(sys_table, "\n");
pascal@20337 217 + }
pascal@20337 218 return status;
pascal@20337 219 }
pascal@20337 220