--- /dev/null
- * Copyright (C) 2007,2008 Free Software Foundation, Inc.
+/*
+ * GRUB -- GRand Unified Bootloader
++ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_AT_KEYBOARD_HEADER
+#define GRUB_AT_KEYBOARD_HEADER 1
+
+#define SHIFT_L 0x2a
+#define SHIFT_R 0x36
+#define CTRL 0x1d
+#define ALT 0x38
+#define CAPS_LOCK 0x3a
++#define NUM_LOCK 0x45
++#define SCROLL_LOCK 0x46
+
+/* Used for sending commands to the controller. */
+#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
+#define KEYBOARD_COMMAND_READ 0x20
+#define KEYBOARD_COMMAND_WRITE 0x60
+#define KEYBOARD_COMMAND_REBOOT 0xfe
+
+#define KEYBOARD_SCANCODE_SET1 0x40
+
+#define KEYBOARD_ISMAKE(x) !((x) & 0x80)
+#define KEYBOARD_ISREADY(x) ((x) & 0x01)
+#define KEYBOARD_SCANCODE(x) ((x) & 0x7f)
+
+#ifdef GRUB_MACHINE_IEEE1275
+#define OLPC_UP GRUB_TERM_UP
+#define OLPC_DOWN GRUB_TERM_DOWN
+#define OLPC_LEFT GRUB_TERM_LEFT
+#define OLPC_RIGHT GRUB_TERM_RIGHT
+#else
+#define OLPC_UP '\0'
+#define OLPC_DOWN '\0'
+#define OLPC_LEFT '\0'
+#define OLPC_RIGHT '\0'
+#endif
+
+#endif
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
if (num > 0xffff)
grub_util_error (_("the core image is too big"));
-
-
++
boot_path = grub_util_get_path (dir, "diskboot.img");
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
- grub_util_error (_("diskboot.img size must be %u bytes"), GRUB_DISK_SECTOR_SIZE);
-
+ grub_util_error (_("diskboot.img size must be %u bytes"),
+ GRUB_DISK_SECTOR_SIZE);
-
++
boot_img = grub_util_read_image (boot_path);
-
-
- /* i386 is a little endian architecture. */
++
*((grub_uint16_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
- GRUB_BOOT_MACHINE_LIST_SIZE + 8))
- = grub_cpu_to_le16 (num);
-
+ = grub_host_to_target16 (num);
-
++
grub_util_write_image (boot_img, boot_size, out);
free (boot_img);
free (boot_path);
#ifdef GRUB_MACHINE_PCBIOS
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
grub_util_error (_("Core image is too big (%p > %p)\n"),
- GRUB_KERNEL_MACHINE_LINK_ADDR + core_size, GRUB_MEMORY_MACHINE_UPPER);
+ GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
+ GRUB_MEMORY_MACHINE_UPPER);
+#endif
+
+#if defined(GRUB_MACHINE_MIPS)
+ if (format == GRUB_PLATFORM_IMAGE_ELF)
+ {
+ char *elf_img;
+ size_t program_size;
+ Elf32_Ehdr *ehdr;
+ Elf32_Phdr *phdr;
+ grub_uint32_t target_addr;
+
+ program_size = ALIGN_UP (core_size, 4);
+
+ elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
+ memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));
+ memcpy (elf_img + sizeof (*ehdr) + sizeof (*phdr), core_img, core_size);
+ ehdr = (void *) elf_img;
+ phdr = (void *) (elf_img + sizeof (*ehdr));
+ memcpy (ehdr->e_ident, ELFMAG, SELFMAG);
+ ehdr->e_ident[EI_CLASS] = ELFCLASS32;
+#ifdef GRUB_CPU_MIPSEL
+ ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
+#else
+ ehdr->e_ident[EI_DATA] = ELFDATA2MSB;
+#endif
+ ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_NONE;
+ ehdr->e_type = grub_host_to_target16 (ET_EXEC);
+ ehdr->e_machine = grub_host_to_target16 (EM_MIPS);
+ ehdr->e_version = grub_host_to_target32 (EV_CURRENT);
+
+ ehdr->e_phoff = grub_host_to_target32 ((char *) phdr - (char *) ehdr);
+ ehdr->e_phentsize = grub_host_to_target16 (sizeof (*phdr));
+ ehdr->e_phnum = grub_host_to_target16 (1);
+
+ /* No section headers. */
+ ehdr->e_shoff = grub_host_to_target32 (0);
+ ehdr->e_shentsize = grub_host_to_target16 (0);
+ ehdr->e_shnum = grub_host_to_target16 (0);
+ ehdr->e_shstrndx = grub_host_to_target16 (0);
-
++
+ ehdr->e_ehsize = grub_host_to_target16 (sizeof (*ehdr));
-
++
+ phdr->p_type = grub_host_to_target32 (PT_LOAD);
+ phdr->p_offset = grub_host_to_target32 (sizeof (*ehdr) + sizeof (*phdr));
+ phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
-
++
+ target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR
+ + kernel_size + total_module_size, 32);
+ ehdr->e_entry = grub_host_to_target32 (target_addr);
+ phdr->p_vaddr = grub_host_to_target32 (target_addr);
+ phdr->p_paddr = grub_host_to_target32 (target_addr);
+ phdr->p_align = grub_host_to_target32 (GRUB_KERNEL_MACHINE_LINK_ALIGN);
+ ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER
+ | EF_MIPS_PIC | EF_MIPS_CPIC);
+ phdr->p_filesz = grub_host_to_target32 (core_size);
+ phdr->p_memsz = grub_host_to_target32 (core_size);
+
+ free (core_img);
+ core_img = elf_img;
+ core_size = program_size + sizeof (*ehdr) + sizeof (*phdr);
+ }
#endif
grub_util_write_image (core_img, core_size, out);